/// </summary>
public static NullLogger Instance { get; } = new NullLogger();
+ /// <summary>
+ /// Initializes a new instance of the <see cref="NullLogger"/> class.
+ /// </summary>
private NullLogger()
{
}
/// <inheritdoc />
public class LoggerProviderOptionsChangeTokenSource<TOptions, TProvider> : ConfigurationChangeTokenSource<TOptions>
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoggerProviderOptionsChangeTokenSource{TOptions, TProvider}"/> class.
+ /// </summary>
public LoggerProviderOptionsChangeTokenSource(ILoggerProviderConfiguration<TProvider> providerConfiguration) : base(providerConfiguration.Configuration)
{
}
/// </summary>
public class ConsoleFormatterOptions
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConsoleFormatterOptions"/> class.
+ /// </summary>
public ConsoleFormatterOptions() { }
/// <summary>
namespace Microsoft.Extensions.Logging.Console
{
+ /// <summary>
+ /// A logger that writes messages in the console.
+ /// </summary>
[UnsupportedOSPlatform("browser")]
internal sealed class ConsoleLogger : ILogger
{
[ThreadStatic]
private static StringWriter? t_stringWriter;
+ /// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel))
_queueProcessor.EnqueueMessage(new LogMessageEntry(computedAnsiString, logAsError: logLevel >= Options.LogToStandardErrorThreshold));
}
+ /// <inheritdoc />
public bool IsEnabled(LogLevel logLevel)
{
return logLevel != LogLevel.None;
}
+ /// <inheritdoc />
public IDisposable BeginScope<TState>(TState state) where TState : notnull => ScopeProvider?.Push(state) ?? NullScope.Instance;
}
}
/// </summary>
public class JsonConsoleFormatterOptions : ConsoleFormatterOptions
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="JsonConsoleFormatterOptions"/> class.
+ /// </summary>
public JsonConsoleFormatterOptions() { }
/// <summary>
/// </summary>
public class SimpleConsoleFormatterOptions : ConsoleFormatterOptions
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SimpleConsoleFormatterOptions"/> class.
+ /// </summary>
public SimpleConsoleFormatterOptions() { }
/// <summary>
return new DebugLogger(name);
}
+ /// <inheritdoc />
public void Dispose()
{
}
_intermediateMessageSegmentSize = EventLog.MaxMessageSize - 2 * ContinuationString.Length;
}
+ /// <summary>
+ /// The event log.
+ /// </summary>
public IEventLog EventLog { get; }
/// <inheritdoc />
namespace Microsoft.Extensions.Logging.EventLog
{
+ /// <summary>
+ /// The windows event log.
+ /// </summary>
[SupportedOSPlatform("windows")]
internal sealed class WindowsEventLog : IEventLog
{
private const int MaximumMessageSize = 31839;
private bool _enabled = true;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="WindowsEventLog"/> class.
+ /// </summary>
public WindowsEventLog(string logName, string machineName, string sourceName)
{
DiagnosticsEventLog = new System.Diagnostics.EventLog(logName, machineName, sourceName);
}
+ /// <summary>
+ /// The diagnostics event log.
+ /// </summary>
public System.Diagnostics.EventLog DiagnosticsEventLog { get; }
+ /// <summary>
+ /// The maximum message size.
+ /// </summary>
public int MaxMessageSize => MaximumMessageSize;
public int? DefaultEventId { get; set; }
return logLevel != LogLevel.None && logLevel >= Level;
}
+ /// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel))
private EventSourceLogger? _loggers; // Linked list of loggers that I have created
private readonly LoggingEventSource _eventSource;
+ /// <summary>
+ /// Creates an instance of <see cref="EventSourceLoggerProvider"/>.
+ /// </summary>
+ /// <param name="eventSource">The logging event source.</param>
public EventSourceLoggerProvider(LoggingEventSource eventSource)
{
ThrowHelper.ThrowIfNull(eventSource);
namespace Microsoft.Extensions.Logging.TraceSource
{
+ /// <summary>
+ /// A logger that writes a trace source log message.
+ /// </summary>
internal sealed class TraceSourceLogger : ILogger
{
private readonly DiagnosticsTraceSource _traceSource;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TraceSourceLogger"/> class.
+ /// </summary>
+ /// <param name="traceSource">trace source</param>
public TraceSourceLogger(DiagnosticsTraceSource traceSource)
{
_traceSource = traceSource;
}
+ /// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel))