-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Taillefer
committed
Jun 21, 2024
1 parent
ceb0a16
commit ca3dbc5
Showing
13 changed files
with
348 additions
and
40 deletions.
There are no files selected for viewing
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
71 changes: 71 additions & 0 deletions
71
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/BufferedLogRecord.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,71 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Microsoft.Extensions.Logging | ||
{ | ||
/// <summary> | ||
/// State representing a buffered log record. | ||
/// </summary> | ||
/// <remarks> | ||
/// Objects of this type are reused over time to reduce | ||
/// allocations. | ||
/// </remarks> | ||
public abstract class BufferedLogRecord | ||
{ | ||
/// <summary> | ||
/// Gets the time when the log record was first created. | ||
/// </summary> | ||
public abstract DateTimeOffset Timestamp { get; } | ||
|
||
/// <summary> | ||
/// Gets the record's log level, indicating it rough importance | ||
/// </summary> | ||
public abstract LogLevel LogLevel { get; } | ||
|
||
/// <summary> | ||
/// Gets the records event id. | ||
/// </summary> | ||
public abstract EventId EventId { get; } | ||
|
||
/// <summary> | ||
/// Gets an optional exception string for this record. | ||
/// </summary> | ||
public abstract string? Exception { get; } | ||
|
||
#if NET8_0_OR_GREATER | ||
/// <summary> | ||
/// Gets an activity span id for this record, representing the state of the thread that created the record. | ||
/// </summary> | ||
public abstract ActivitySpanId ActivitySpanId { get; } | ||
|
||
/// <summary> | ||
/// Gets an activity trace id for this record, representing the state of the thread that created the record. | ||
/// </summary> | ||
public abstract ActivityTraceId ActivityTraceId { get; } | ||
#endif | ||
|
||
/// <summary> | ||
/// Gets the ID of the thread that created the log record. | ||
/// </summary> | ||
public abstract int? ManagedThreadId { get; } | ||
|
||
/// <summary> | ||
/// Gets the formatted log message. | ||
/// </summary> | ||
public abstract string? FormattedMessage { get; } | ||
|
||
/// <summary> | ||
/// Gets the original log message template. | ||
/// </summary> | ||
public abstract string? MessageTemplate { get; } | ||
|
||
/// <summary> | ||
/// Gets the variable set of name/value pairs associated with the record. | ||
/// </summary> | ||
public abstract IReadOnlyList<KeyValuePair<string, object?>> Attributes { get; } | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/IBufferedLogger.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,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Extensions.Logging | ||
{ | ||
/// <summary> | ||
/// Logging providers can implement this interface to indicate they support buffered logging. | ||
/// </summary> | ||
/// <remarks> | ||
/// A logging provider normally exposes an <see cref="ILogger" /> interface that gets invoked by the | ||
/// logging infrastructure whenever it’s time to log a piece of state. | ||
/// | ||
/// The logging infrastructure will type-test the <c>ILogger</c> object to determine if | ||
/// it supports the <c>IBufferedLogger</c> interface also. If it does, that tells the | ||
/// logging infrastructure that the logging provider supports buffering. Whenever log | ||
/// buffering is enabled, buffered log records will be delivered to the logging provider | ||
/// via the <c>IBufferedLogger</c> interface. | ||
/// | ||
/// If a logging provider does not support log buffering, then it will always be given | ||
/// unbuffered log records. In other words, whether or not buffering is requested by | ||
/// the user, it will not happen for those log providers. | ||
/// </remarks> | ||
public interface IBufferedLogger | ||
{ | ||
/// <summary> | ||
/// Delivers a batch of buffered log records to a logging provider. | ||
/// </summary> | ||
/// <param name="records">The buffered log records to log.</param> | ||
/// <remarks> | ||
/// Once this function returns, it should no longer access the records | ||
/// or state referenced by these records. | ||
/// </remarks> | ||
void Log(IReadOnlyList<BufferedLogRecord> records); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/src.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.Logging.Abstractions.csproj", "{2C37E902-3EB9-4E48-82DB-9D4C4BB6AAD0}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2C37E902-3EB9-4E48-82DB-9D4C4BB6AAD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2C37E902-3EB9-4E48-82DB-9D4C4BB6AAD0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2C37E902-3EB9-4E48-82DB-9D4C4BB6AAD0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2C37E902-3EB9-4E48-82DB-9D4C4BB6AAD0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {69124FB1-1525-4BBA-AB0C-0E6753566E44} | ||
EndGlobalSection | ||
EndGlobal |
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
Oops, something went wrong.