55using  System . Text ; 
66using  Microsoft . Extensions . Logging ; 
77
8+ #if NET9_0_OR_GREATER 
9+ using  System . Threading ; 
10+ #endif
11+ 
812namespace  Stravaig . Extensions . Logging . Diagnostics ; 
913
1014/// <summary> 
@@ -14,45 +18,49 @@ namespace Stravaig.Extensions.Logging.Diagnostics;
1418public  class  LogEntry  :  IComparable < LogEntry > 
1519{ 
1620    private  static   int  _sequence ; 
17-     private  static   readonly  object  SequenceSyncLock  =  new  ( ) ; 
21+ #if NET9_0_OR_GREATER 
22+     private  static   readonly  Lock  SequenceSyncLock  =  new ( ) ; 
23+ #else
24+     private  static   readonly  object  SequenceSyncLock  =  new ( ) ; 
25+ #endif
1826
1927    private  const  string  OriginalMessagePropertyName  =  "{OriginalFormat}" ; 
20-          
28+ 
2129    private  readonly  Lazy < IReadOnlyDictionary < string ,  object > >  _lazyPropertyDictionary ; 
22-          
30+ 
2331    /// <summary> 
2432    /// The <see cref="T:Microsoft.Extensions.Logging.LogLevel"/> that the item was logged at. 
2533    /// </summary> 
2634    public  LogLevel  LogLevel  {  get ;  } 
27-          
35+ 
2836    /// <summary> 
2937    /// An <see cref="T:Microsoft.Extensions.Logging.EventId"/> that identifies a logging event. 
3038    /// </summary> 
3139    public  EventId  EventId  {  get ;  } 
32-          
40+ 
3341    /// <summary> 
3442    /// The entry to be written. Can be also an object. 
3543    /// </summary> 
3644    public  object ?  State  {  get ;  } 
37-          
45+ 
3846    /// <summary> 
3947    /// The <see cref="T:System.Exception"/> that was attached to the log. 
4048    /// </summary> 
4149    public  Exception ?  Exception  {  get ;  } 
42-          
50+ 
4351    /// <summary> 
4452    /// The formatted message. 
4553    /// </summary> 
4654    public  string  FormattedMessage  {  get ;  } 
47-          
55+ 
4856    /// <summary> 
4957    /// The sequence number of the log message. 
5058    /// </summary> 
51-     /// <remarks>In a multi-threaded  environment there may be gaps between adjacent log messages.</remarks> 
59+     /// <remarks>In a multithreaded  environment there may be gaps between adjacent log messages.</remarks> 
5260    public  int  Sequence  {  get ;  } 
53-          
61+ 
5462    /// <summary> 
55-     /// The time the log entry was created in UTC.   
63+     /// The time the log entry was created in UTC. 
5664    /// </summary> 
5765    public  DateTime  TimestampUtc  {  get ;  } 
5866
@@ -74,7 +82,7 @@ public DateTimeOffset TimestampLocal
7482    /// </summary> 
7583    public  IReadOnlyList < KeyValuePair < string ,  object > >  Properties  => 
7684        State  as  IReadOnlyList < KeyValuePair < string ,  object > >  ??  Array . Empty < KeyValuePair < string ,  object > > ( ) ; 
77-          
85+ 
7886    /// <summary> 
7987    /// The properties, if any, for the log entry. 
8088    /// </summary> 
@@ -87,7 +95,7 @@ public DateTimeOffset TimestampLocal
8795        ( string )  Properties 
8896            . FirstOrDefault ( p =>  p . Key  ==  OriginalMessagePropertyName ) 
8997            . Value ; 
90-          
98+ 
9199    /// <summary> 
92100    /// The category name of the log entry, if available. 
93101    /// </summary> 
@@ -178,4 +186,4 @@ public override string ToString()
178186    } 
179187
180188    private  string  DebuggerDisplayString  =>  $ "[#{ Sequence }  @ { TimestampLocal : HH:mm:ss.fff zzz}  { LogLevel }  { CategoryName } ] { FormattedMessage } "; 
181- } 
189+ } 
0 commit comments