@@ -185,24 +185,35 @@ public void LogDebug(IEngine sender, EngineMessageEventArgs e)
185185 /// <param name="level">Log level.</param>
186186 private void WriteLog ( IEngine sender , EngineMessageEventArgs e , log4net . Core . Level level )
187187 {
188- string att = GetAttString ( e . TargetPath ?? e . SourcePath ) ;
188+ string attSource = GetAttString ( e . SourcePath ) ;
189+ string attTarget = GetAttString ( e . TargetPath ) ;
190+
189191 string process = null ;
190192 byte ? priorityHint = null ;
191193 string fileId = null ;
192194 string size = null ;
193195
194196 if ( e . OperationContext != null )
195197 {
196- process = System . IO . Path . GetFileName ( e . OperationContext . ProcessInfo ? . ImagePath ) ;
197- priorityHint = e . OperationContext . PriorityHint ;
198- fileId = ( e . OperationContext as IWindowsOperationContext ) . FileId . ToString ( ) ;
199- size = FormatBytes ( ( e . OperationContext as IWindowsOperationContext ) . FileSize ) ;
198+ process = System . IO . Path . GetFileName ( e . OperationContext ? . ProcessInfo ? . ImagePath ) ;
199+ priorityHint = e . OperationContext ? . PriorityHint ;
200+ IWindowsOperationContext ocWin = e . OperationContext as IWindowsOperationContext ;
201+ if ( ocWin != null )
202+ {
203+ fileId = ocWin . FileId . ToString ( ) ;
204+ size = FormatBytes ( ( e . OperationContext as IWindowsOperationContext ) . FileSize ) ;
205+ }
200206 }
201207
202208 string sourcePath = e . SourcePath ? . FitString ( sourcePathWidth , 6 ) ;
203209 string targetPath = e . TargetPath ? . FitString ( sourcePathWidth , 6 ) ;
204210
205- 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 ) ;
211+ 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 , attSource ) ;
212+ if ( targetPath != null )
213+ {
214+ // For move operation output target path in the next line.
215+ message += Format ( null , null , null , null , null , null , null , null , null , null , targetPath , attTarget ) ;
216+ }
206217
207218 if ( level == log4net . Core . Level . Error )
208219 {
@@ -224,10 +235,10 @@ private void WriteLog(IEngine sender, EngineMessageEventArgs e, log4net.Core.Lev
224235
225236 }
226237
227- private static string Format ( string date , string process , string priorityHint , string fileId , string remoteStorageId , string componentName , string callerLineNumber , string callerMemberName , string callerFilePath , string message , string sourcePath , string attributes , string targetPath )
238+ private static string Format ( string date , string process , string priorityHint , string fileId , string remoteStorageId , string componentName , string callerLineNumber , string callerMemberName , string callerFilePath , string message , string path , string attributes )
228239 {
229240 // {fileId,-18} | {remoteStorageId,-remoteStorageIdWidth}
230- return $ "{ Environment . NewLine } |{ date , - 12 } | { process , - 25 } | { priorityHint , - 5 } | { componentName , - 26 } | { callerLineNumber , 4 } | { message , - 45 } | { sourcePath , - sourcePathWidth } | { attributes , 10 } | { targetPath } ";
241+ return $ "{ Environment . NewLine } |{ date , - 12 } | { process , - 25 } | { componentName , - 26 } | { message , - 45 } | { path , - sourcePathWidth } | { attributes , 10 } ";
231242 }
232243
233244 /// <summary>
@@ -236,8 +247,8 @@ private static string Format(string date, string process, string priorityHint, s
236247 private void PrintHeader ( )
237248 {
238249 log . Info ( "\n " ) ;
239- 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 ") ) ;
240- log . Info ( Format ( "----" , "------------" , "----" , "_____" , "_____" , "---------" , "____" , "------------------" , "----------------" , "-------" , "----------- " , "----------" , "- ----------") ) ;
250+ log . Info ( Format ( "Time" , "Process Name" , "Prty" , "FS ID" , "RS ID" , "Component" , "Line" , "Caller Member Name" , "Caller File Path" , "Message" , "Path" , "Attributes" ) ) ;
251+ log . Info ( Format ( "----" , "------------" , "----" , "_____" , "_____" , "---------" , "____" , "------------------" , "----------------" , "-------" , "----" , "----------" ) ) ;
241252 }
242253
243254 /// <summary>
@@ -247,14 +258,15 @@ private void PrintHeader()
247258 /// <returns>String that represents file or folder attributes or null if the file/folder is not found.</returns>
248259 public static string GetAttString ( string path )
249260 {
261+ if ( path == null )
262+ return null ;
263+
250264 if ( WindowsFileSystemItem . TryGetAttributes ( path , out System . IO . FileAttributes ? attributes ) )
251265 {
252266 return WindowsFileSystemItem . GetFileAttributesString ( attributes . Value ) ;
253267 }
254- else
255- {
256- return null ;
257- }
268+
269+ return null ;
258270 }
259271
260272 /// <summary>
0 commit comments