From a4d4a8d869263a76ef9540ae20b1583949b381ed Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 26 Jul 2016 14:55:08 +1000 Subject: [PATCH 1/3] Dev version bump [Skip CI] --- src/Serilog.Extensions.Logging/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": { From 4049922adb6afd562ca6167b94fd62f66f5fe952 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 1 Aug 2016 07:39:02 +1000 Subject: [PATCH 2/3] Allow the provider to be embedded in other providers by making SerilogLoggerProvider public --- .../Logging/SerilogLoggerProvider.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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(); From 2f28af49eec0e3cf1996884e38f6b4bd08d71608 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Thu, 4 Aug 2016 09:43:21 +1000 Subject: [PATCH 3/3] Changelist [Skip CI] --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) 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