11using Newtonsoft . Json ;
2+
23using System ;
34using System . Collections . Generic ;
45using System . Globalization ;
@@ -221,7 +222,6 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin
221222
222223 Column [ ] columns = Column . CreateColumns ( COLUMN_COUNT , clogLine ) ;
223224
224-
225225 // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
226226 // in colum 8 (the log message column). Date and time column will be left blank.
227227 if ( line . FullLine . Length < 15 )
@@ -233,10 +233,12 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin
233233 try
234234 {
235235 DateTime dateTime = GetTimestamp ( callback , line ) ;
236+
236237 if ( dateTime == DateTime . MinValue )
237238 {
238239 columns [ 8 ] . FullValue = line . FullLine ;
239240 }
241+
240242 string newDate = dateTime . ToString ( DATETIME_FORMAT ) ;
241243 columns [ 0 ] . FullValue = newDate ;
242244 }
@@ -305,6 +307,7 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
305307 }
306308
307309 int endIndex = line . FullLine . IndexOf ( separatorChar , 1 ) ;
310+
308311 if ( endIndex > 20 || endIndex < 0 )
309312 {
310313 return DateTime . MinValue ;
@@ -314,12 +317,12 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
314317 try
315318 {
316319 // convert log4j timestamp into a readable format:
317- long timestamp ;
318- if ( long . TryParse ( value , out timestamp ) )
320+ if ( long . TryParse ( value , out long timestamp ) )
319321 {
320322 // Add the time offset before returning
321323 DateTime dateTime = new ( 1970 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) ;
322324 dateTime = dateTime . AddMilliseconds ( timestamp ) ;
325+
323326 if ( _config . localTimestamps )
324327 {
325328 dateTime = dateTime . ToLocalTime ( ) ;
@@ -347,7 +350,7 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va
347350 DateTime oldDateTime = DateTime . ParseExact ( oldValue , DATETIME_FORMAT , cultureInfo ) ;
348351 long mSecsOld = oldDateTime . Ticks / TimeSpan . TicksPerMillisecond ;
349352 long mSecsNew = newDateTime . Ticks / TimeSpan . TicksPerMillisecond ;
350- timeOffset = ( int ) ( mSecsNew - mSecsOld ) ;
353+ timeOffset = ( int ) ( mSecsNew - mSecsOld ) ;
351354 }
352355 catch ( FormatException )
353356 {
@@ -411,10 +414,7 @@ public Priority GetPriority(string fileName, IEnumerable<ILogLine> samples)
411414
412415 #region Private Methods
413416
414- private string [ ] GetAllColumnNames ( )
415- {
416- return [ "Timestamp" , "Level" , "Logger" , "Thread" , "Class" , "Method" , "File" , "Line" , "Message" ] ;
417- }
417+ private string [ ] GetAllColumnNames ( ) => [ "Timestamp" , "Level" , "Logger" , "Thread" , "Class" , "Method" , "File" , "Line" , "Message" ] ;
418418
419419
420420 /// <summary>
@@ -442,7 +442,7 @@ private Column[] MapColumns(Column[] cols)
442442 }
443443
444444
445- return output . ToArray ( ) ;
445+ return [ .. output ] ;
446446 }
447447
448448 #endregion
0 commit comments