diff --git a/CHANGES.md b/CHANGES.md index c8e55a8..cb900c4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ +1.2.0 + + * #45 - Make the provider type public so that it can be embedded more easily in other providers + 1.1.0 + * #41 - Provide a `dispose` flag to instruct provider to take ownership of the Serilog logger 1.0.0 + * Initial version diff --git a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs index 72b010c..af9b0ad 100644 --- a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs +++ b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs @@ -15,14 +15,22 @@ namespace Serilog.Extensions.Logging { - class SerilogLoggerProvider : ILoggerProvider, ILogEventEnricher + /// + /// An that pipes events through Serilog. + /// + public class SerilogLoggerProvider : ILoggerProvider, ILogEventEnricher { - public const string OriginalFormatPropertyName = "{OriginalFormat}"; + internal const string OriginalFormatPropertyName = "{OriginalFormat}"; // May be null; if it is, Log.Logger will be lazily used readonly ILogger _logger; readonly Action _dispose; + /// + /// Construct a . + /// + /// A Serilog logger to pipe events through; if null, the static class will be used. + /// If true, the provided logger or static log class will be disposed/closed when the provider is disposed. public SerilogLoggerProvider(ILogger logger = null, bool dispose = false) { if (logger != null) @@ -37,16 +45,19 @@ public SerilogLoggerProvider(ILogger logger = null, bool dispose = false) } } + /// public FrameworkLogger CreateLogger(string name) { return new SerilogLogger(this, _logger, name); } + /// public IDisposable BeginScope(T state) { return new SerilogLoggerScope(this, state); } + /// public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { for (var scope = CurrentScope; scope != null; scope = scope.Parent) @@ -58,7 +69,7 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) #if ASYNCLOCAL readonly AsyncLocal _value = new AsyncLocal(); - public SerilogLoggerScope CurrentScope + internal SerilogLoggerScope CurrentScope { get { @@ -72,7 +83,7 @@ public SerilogLoggerScope CurrentScope #else readonly string _currentScopeKey = nameof(SerilogLoggerScope) + "#" + Guid.NewGuid().ToString("n"); - public SerilogLoggerScope CurrentScope + internal SerilogLoggerScope CurrentScope { get { @@ -86,6 +97,7 @@ public SerilogLoggerScope CurrentScope } #endif + /// public void Dispose() { _dispose?.Invoke(); diff --git a/src/Serilog.Extensions.Logging/project.json b/src/Serilog.Extensions.Logging/project.json index 000eb27..46cfca9 100644 --- a/src/Serilog.Extensions.Logging/project.json +++ b/src/Serilog.Extensions.Logging/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "description": "Serilog provider for Microsoft.Extensions.Logging", "authors": [ "Microsoft", "Serilog Contributors" ], "packOptions": {