diff --git a/README.md b/README.md index d9ec49d..f0337f8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ When you install the package, it should be added to your `package.json`. Alterna ```json { "dependencies" : { - "ZNetCS.AspNetCore.Logging.EntityFrameworkCore": "1.0.1" + "ZNetCS.AspNetCore.Logging.EntityFrameworkCore": "1.0.2" } } ``` diff --git a/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/EntityFrameworkLogger.cs b/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/EntityFrameworkLogger.cs index 678db02..cf170c8 100644 --- a/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/EntityFrameworkLogger.cs +++ b/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/EntityFrameworkLogger.cs @@ -121,21 +121,11 @@ public class EntityFrameworkLogger : IEntityFrameworkLogge { #region Fields - /// - /// The function used to create new model instance for a log. - /// - private readonly Func creator; - /// /// The function used to filter events based on the log level. /// private readonly Func filter; - /// - /// The name of the logger. - /// - private readonly string name; - /// /// The service provider to resolve dependency. /// @@ -178,13 +168,28 @@ public EntityFrameworkLogger( this.serviceProvider = serviceProvider; - this.name = name ?? string.Empty; this.filter = filter; - this.creator = creator ?? this.DefaultCreator; + + this.Name = name ?? string.Empty; + this.Creator = creator ?? this.DefaultCreator; } #endregion + #region Properties + + /// + /// Gets the function used to create new model instance for a log. + /// + protected virtual Func Creator { get; } + + /// + /// Gets the name of the logger. + /// + protected virtual string Name { get; } + + #endregion + #region Implemented Interfaces #region ILogger @@ -198,7 +203,7 @@ public virtual IDisposable BeginScope(TState state) /// public virtual bool IsEnabled(LogLevel logLevel) { - return (this.filter == null) || this.filter(this.name, logLevel); + return (this.filter == null) || this.filter(this.Name, logLevel); } /// @@ -255,7 +260,7 @@ protected virtual void WriteMessage(string message, LogLevel logLevel, int event using (var context = ActivatorUtilities.CreateInstance(this.serviceProvider)) { // create new log with resolving dependency injection - TLog log = this.creator((int)logLevel, eventId, this.name, message); + TLog log = this.Creator((int)logLevel, eventId, this.Name, message); context.Set().Add(log); diff --git a/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/project.json b/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/project.json index f5d1a11..44c301f 100644 --- a/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/project.json +++ b/src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.1", + "version": "1.0.2", "packOptions": { "owners": [ "Marcin Smółka" ], "licenseUrl": "https://raw.githubusercontent.com/msmolka/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/master/LICENSE",