77
88namespace MELT
99{
10+ /// <summary>
11+ /// Represents a log entry captured from Serilog during testing.
12+ /// </summary>
1013 public class SerilogLogEntry
1114 {
15+ #pragma warning disable CS0612 // Type or member is obsolete
1216 private readonly WriteContext _writeContext ;
17+ #pragma warning restore CS0612 // Type or member is obsolete
1318 private static readonly IReadOnlyList < LogEventPropertyValue > _emptyProperties = new LogEventPropertyValue [ 0 ] ;
1419 private string ? _format ;
1520 private IReadOnlyList < LogEventPropertyValue > ? _scope ;
1621
22+ /// <summary>
23+ /// Initializes a new instance of the <see cref="SerilogLogEntry"/> class.
24+ /// </summary>
25+ /// <param name="writeContext">The write context containing log information.</param>
26+ [ Obsolete ]
1727 public SerilogLogEntry ( WriteContext writeContext )
1828 {
1929 _writeContext = writeContext ;
2030 }
2131
32+ /// <summary>
33+ /// Gets the event ID for this log entry.
34+ /// </summary>
2235 public EventId EventId => _writeContext . EventId ;
36+
37+ /// <summary>
38+ /// Gets the exception associated with this log entry, if any.
39+ /// </summary>
2340 public Exception ? Exception => _writeContext . Exception ;
41+
42+ /// <summary>
43+ /// Gets the name of the logger that created this log entry.
44+ /// </summary>
2445 public string LoggerName => _writeContext . LoggerName ;
46+
47+ /// <summary>
48+ /// Gets the log level of this log entry.
49+ /// </summary>
2550 public LogLevel LogLevel => _writeContext . LogLevel ;
51+
52+ /// <summary>
53+ /// Gets the formatted log message.
54+ /// </summary>
2655 public string ? Message => _writeContext . Message ;
56+
57+ /// <summary>
58+ /// Gets the properties associated with this log entry.
59+ /// </summary>
2760 public IReadOnlyList < KeyValuePair < string , object > > Properties => _writeContext . State as IReadOnlyList < KeyValuePair < string , object > > ?? Constants . EmptyProperties ;
2861
62+ /// <summary>
63+ /// Gets the original format of the log message before parameter substitution.
64+ /// </summary>
2965 public string OriginalFormat => _format ??= GetFormat ( ) ;
30-
3166 private string GetFormat ( )
3267 {
3368 foreach ( var prop in Properties )
@@ -45,9 +80,18 @@ private string GetFormat()
4580 return Constants . NullString ;
4681 }
4782
83+ /// <summary>
84+ /// Gets the scope values from Serilog log entry.
85+ /// </summary>
86+ /// <remarks>
87+ /// This property is obsolete. Use <see cref="Scopes"/> instead.
88+ /// </remarks>
4889 [ Obsolete ( "The recommended alternative is " + nameof ( Scopes ) + "." ) ]
4990 public IReadOnlyList < LogEventPropertyValue > Scope => _scope ??= GetSerilogScopes ( ) ;
5091
92+ /// <summary>
93+ /// Gets the scope values from Serilog log entry.
94+ /// </summary>
5195 public IReadOnlyList < LogEventPropertyValue > Scopes => _scope ??= GetSerilogScopes ( ) ;
5296
5397 private IReadOnlyList < LogEventPropertyValue > GetSerilogScopes ( )
0 commit comments