-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce IBufferedLogRecordMetadata
- Loading branch information
Martin Taillefer
committed
Jun 7, 2024
1 parent
0afe5e1
commit 356da75
Showing
6 changed files
with
165 additions
and
12 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/BufferedLogRecordMetadata.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
#if NET8_0_OR_GREATER | ||
using System.Diagnostics; | ||
#endif | ||
|
||
namespace Microsoft.Extensions.Logging | ||
{ | ||
/// <summary> | ||
/// Holds metadata for a buffered log record. | ||
/// </summary> | ||
public struct BufferedLogRecordMetadata | ||
{ | ||
/// <summary> | ||
/// Gets the time when the log record was recorded. | ||
/// </summary> | ||
public DateTimeOffset CreationTime { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the thread that created the log record. | ||
/// </summary> | ||
public int? ManagedThreadId { get; set; } | ||
|
||
#if NET8_0_OR_GREATER | ||
/// <summary> | ||
/// Gets the ID of the span in effect when the log record was created. | ||
/// </summary> | ||
public ActivitySpanId? SpanId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the trace in effect when the log record was created. | ||
/// </summary> | ||
public ActivityTraceId? TraceId { get; set; } | ||
#endif | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/IBufferedLogRecord.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.Extensions.Logging | ||
{ | ||
/// <summary> | ||
/// A buffered log record. | ||
/// </summary> | ||
/// <remarks> | ||
/// If the logging infrastructure decides to buffer log records in memory, it will ensure that the | ||
/// <c>TState</c> value delivered to logging providers implements this interface. The logging providers | ||
/// can then use the metadata to augment the log records they emit. | ||
/// </remarks> | ||
public interface IBufferedLogRecord | ||
{ | ||
/// <summary> | ||
/// Extracts the metadata for the buffered log record. | ||
/// </summary> | ||
public void ExtractMetadata(out BufferedLogRecordMetadata metadata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters