@@ -83,7 +83,7 @@ private string ConfigureLogger()
8383 }
8484
8585 /// <summary>
86- /// Prints environment description.
86+ /// Prints environment description and console commands .
8787 /// </summary>
8888 public void PrintEnvironmentDescription ( )
8989 {
@@ -94,30 +94,46 @@ public void PrintEnvironmentDescription()
9494 log . Info ( $ "\n { ".NET version:" , - 25 } { RuntimeInformation . FrameworkDescription } { IntPtr . Size * 8 } bit.") ;
9595 log . Info ( $ "\n { "Package or app identity:" , - 25 } { PackageRegistrar . IsRunningWithIdentity ( ) } ") ;
9696 log . Info ( $ "\n { "Sparse package identity:" , - 25 } { PackageRegistrar . IsRunningWithSparsePackageIdentity ( ) } ") ;
97- log . Info ( $ "\n { "Elevated mode:" , - 25 } { new System . Security . Principal . WindowsPrincipal ( System . Security . Principal . WindowsIdentity . GetCurrent ( ) ) . IsInRole ( System . Security . Principal . WindowsBuiltInRole . Administrator ) } ") ;
97+ log . Info ( $ "\n { "Elevated mode:" , - 25 } { new System . Security . Principal . WindowsPrincipal ( System . Security . Principal . WindowsIdentity . GetCurrent ( ) ) . IsInRole ( System . Security . Principal . WindowsBuiltInRole . Administrator ) } ") ;
98+
99+ string sparsePackagePath = PackageRegistrar . GetSparsePackagePath ( ) ;
100+ if ( File . Exists ( sparsePackagePath ) )
101+ {
102+ log . Info ( $ "\n { "Sparse package location:" , - 25 } { sparsePackagePath } ") ;
103+ var cert = System . Security . Cryptography . X509Certificates . X509Certificate . CreateFromSignedFile ( sparsePackagePath ) ;
104+ log . Info ( $ "\n { "Sparse package cert:" , - 25 } Subject: { cert . Subject } , Issued by: { cert . Issuer } ") ;
105+ }
106+ else
107+ {
108+ log . Info ( $ "\n { "Sparse package:" , - 25 } Not found") ;
109+ }
110+
111+ // Log console commands.
112+ PrintHelp ( ) ;
98113 }
99114
100115 /// <summary>
101- /// Print Engine config, settings, console commands, logging headers.
116+ /// Print Engine config, settings, logging headers.
102117 /// </summary>
103118 /// <param name="engine">Engine instance.</param>
104119 /// <param name="remoteStorageRootPath">Remote storage root path.</param>
105120 public async Task PrintEngineStartInfoAsync ( EngineWindows engine )
106121 {
107122 await PrintEngineEnvironmentDescriptionAsync ( engine ) ;
108-
109- // Log console commands.
110- PrintHelp ( ) ;
123+ log . Info ( "\n " ) ;
111124
112125 // Log logging columns headers.
113126 PrintHeader ( ) ;
114127 }
115128
116129 public async Task PrintEngineEnvironmentDescriptionAsync ( EngineWindows engine )
117130 {
131+ log . Info ( $ "\n ") ;
118132 log . Info ( $ "\n { "File system root:" , - 25 } { engine . Path } ") ;
119133 log . Info ( $ "\n { "Remote storage root:" , - 25 } { remoteStorageRootPath } ") ;
120134 log . Info ( $ "\n { "AutoLock:" , - 25 } { engine . AutoLock } ") ;
135+ log . Info ( $ "\n { "Outgoing sync, ms:" , - 25 } { engine . SyncService . SyncIntervalMs } ") ;
136+
121137
122138 // Log indexing state. Sync root must be indexed.
123139 await PrintIndexingStateAsync ( engine . Path ) ;
@@ -138,16 +154,23 @@ private async Task PrintIndexingStateAsync(string path)
138154 /// </summary>
139155 public void PrintHelp ( )
140156 {
141- log . Info ( "\n \n Press Esc to unregister file system, delete all files/folders, unregister sparse package, unregister handlers and exit (simulate uninstall)." ) ;
142- log . Info ( "\n Press Spacebar to exit without unregistering (simulate reboot)." ) ;
143- log . Info ( "\n Press 'p' to unregister file system, delete all files/folders, developer certificate, unregister sparse package, unregister handlers and exit (simulate full uninstall)." ) ;
144- log . Info ( "\n Press 'e' to start/stop the Engine and all sync services." ) ;
145- log . Info ( "\n Press 's' to start/stop synchronization service." ) ;
146- log . Info ( "\n Press 'm' to start/stop remote storage monitor." ) ;
147- log . Info ( "\n Press 'd' to enable/disable debug and performance logging." ) ;
148- log . Info ( $ "\n Press 'l' to open log file. ({ LogFilePath } )") ;
149- log . Info ( $ "\n Press 'b' to submit support tickets, report bugs, suggest features. (https://userfilesystem.com/support/)") ;
150- log . Info ( "\n ----------------------\n " ) ;
157+ log . Info ( "\n \n ----------------------------------------------------------------------------------------" ) ;
158+ log . Info ( "\n Commands:" ) ;
159+ PrintCommandDescription ( "Spacebar" , "Exit without unregistering (simulate reboot)" ) ;
160+ PrintCommandDescription ( "Esc" , "Unregister file system, delete all files/folders, unregister handlers and exit." ) ;
161+ PrintCommandDescription ( "Shift-Esc" , "Unregister file system, delete all files/folders, unregister handlers, uninstall developer certificate, unregister sparse package and exit (simulate full uninstall)." ) ;
162+ PrintCommandDescription ( "e" , "Start/stop the Engine and all sync services." ) ;
163+ PrintCommandDescription ( "s" , "Start/stop synchronization service." ) ;
164+ PrintCommandDescription ( "m" , "Start/stop remote storage monitor." ) ;
165+ PrintCommandDescription ( "d" , "Enable/disable debug and performance logging." ) ;
166+ PrintCommandDescription ( "l" , $ "Open log file. ({ LogFilePath } )") ;
167+ PrintCommandDescription ( "b" , "Submit support tickets, report bugs, suggest features. (https://userfilesystem.com/support/)" ) ;
168+ log . Info ( "\n ----------------------------------------------------------------------------------------" ) ;
169+ }
170+
171+ private void PrintCommandDescription ( string key , string description )
172+ {
173+ log . Info ( $ "{ Environment . NewLine } { key , 12 } - { description , - 25 } ") ;
151174 }
152175
153176 public void LogError ( IEngine sender , EngineErrorEventArgs e )
@@ -190,16 +213,6 @@ private void WriteLog(IEngine sender, EngineMessageEventArgs e, log4net.Core.Lev
190213 string sourcePath = e . SourcePath ? . FitString ( sourcePathWidth , 6 ) ;
191214 string targetPath = e . TargetPath ? . FitString ( sourcePathWidth , 6 ) ;
192215
193- // Trim sync root and remote storage root to reduce ammount of logging and improve logs readability
194- //if (sender != null)
195- //{
196- //sourcePath = sourcePath?.Replace((sender as EngineWindows).Path, "<FS root>");
197- //sourcePath = sourcePath?.Replace(remoteStorageRootPath, "<RS root>");
198-
199- //targetPath = targetPath?.Replace((sender as EngineWindows).Path, "<FS root>");
200- //targetPath = targetPath?.Replace(remoteStorageRootPath, "<RS root>");
201- //}
202-
203216 string message = Format ( DateTimeOffset . Now . ToString ( "hh:mm:ss.fff" ) , process , priorityHint ? . ToString ( ) , fileId , "" , e . ComponentName , e . CallerLineNumber . ToString ( ) , e . CallerMemberName , e . CallerFilePath , e . Message , sourcePath , att , targetPath ) ;
204217
205218 if ( level == log4net . Core . Level . Error )
@@ -233,6 +246,7 @@ private static string Format(string date, string process, string priorityHint, s
233246 /// </summary>
234247 private void PrintHeader ( )
235248 {
249+ log . Info ( "\n " ) ;
236250 log . Info ( Format ( "Time" , "Process Name" , "Prty" , "FS ID" , "RS ID" , "Component" , "Line" , "Caller Member Name" , "Caller File Path" , "Message" , "Source Path" , "Attributes" , "Target Path" ) ) ;
237251 log . Info ( Format ( "----" , "------------" , "----" , "_____" , "_____" , "---------" , "____" , "------------------" , "----------------" , "-------" , "-----------" , "----------" , "-----------" ) ) ;
238252 }
0 commit comments