From ac28a2a48f20412d52516b00bbff596e49937db4 Mon Sep 17 00:00:00 2001 From: janskoruba Date: Tue, 21 Dec 2021 21:22:29 +0100 Subject: [PATCH 1/2] Update to NET6 and add option to disable audit logging --- .../Skoruba.AuditLogging.EntityFramework.csproj | 6 +++--- .../Skoruba.AuditLogging.Host.csproj | 14 +++++--------- src/Skoruba.AuditLogging.Host/Startup.cs | 1 + .../Configuration/AuditLoggerOptions.cs | 6 ++++++ .../Services/AuditEventLogger.cs | 5 +++++ .../Skoruba.AuditLogging.csproj | 10 +++++----- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/Skoruba.AuditLogging.EntityFramework/Skoruba.AuditLogging.EntityFramework.csproj b/src/Skoruba.AuditLogging.EntityFramework/Skoruba.AuditLogging.EntityFramework.csproj index fb0c774..e3248b4 100644 --- a/src/Skoruba.AuditLogging.EntityFramework/Skoruba.AuditLogging.EntityFramework.csproj +++ b/src/Skoruba.AuditLogging.EntityFramework/Skoruba.AuditLogging.EntityFramework.csproj @@ -1,8 +1,8 @@  - netcoreapp3.1 - 1.0.0 + net6.0 + 1.1.0 Simple audit logging for .NET Core with EntityFramework Core support https://github.com/skoruba/AuditLogging @@ -14,7 +14,7 @@ - + diff --git a/src/Skoruba.AuditLogging.Host/Skoruba.AuditLogging.Host.csproj b/src/Skoruba.AuditLogging.Host/Skoruba.AuditLogging.Host.csproj index a30c3c1..ba40787 100644 --- a/src/Skoruba.AuditLogging.Host/Skoruba.AuditLogging.Host.csproj +++ b/src/Skoruba.AuditLogging.Host/Skoruba.AuditLogging.Host.csproj @@ -1,22 +1,18 @@  - netcoreapp3.1 + net6.0 InProcess 5cc61b65-f1d1-4aa9-be20-fbf67d81e116 - - - - - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/Skoruba.AuditLogging.Host/Startup.cs b/src/Skoruba.AuditLogging.Host/Startup.cs index 3369081..06879d0 100644 --- a/src/Skoruba.AuditLogging.Host/Startup.cs +++ b/src/Skoruba.AuditLogging.Host/Startup.cs @@ -45,6 +45,7 @@ public void ConfigureServices(IServiceCollection services) services.AddAuditLogging(options => { + options.Enabled = true; options.UseDefaultAction = true; options.UseDefaultSubject = true; options.Source = typeof(Program).Assembly.GetName().Name; diff --git a/src/Skoruba.AuditLogging/Configuration/AuditLoggerOptions.cs b/src/Skoruba.AuditLogging/Configuration/AuditLoggerOptions.cs index 019ff03..4668c2e 100644 --- a/src/Skoruba.AuditLogging/Configuration/AuditLoggerOptions.cs +++ b/src/Skoruba.AuditLogging/Configuration/AuditLoggerOptions.cs @@ -2,6 +2,12 @@ { public class AuditLoggerOptions { + + public bool Enabled { get; set; } = true; + + /// + /// Name of source + /// public string Source { get; set; } /// diff --git a/src/Skoruba.AuditLogging/Services/AuditEventLogger.cs b/src/Skoruba.AuditLogging/Services/AuditEventLogger.cs index 2b82d02..222702d 100644 --- a/src/Skoruba.AuditLogging/Services/AuditEventLogger.cs +++ b/src/Skoruba.AuditLogging/Services/AuditEventLogger.cs @@ -108,6 +108,11 @@ private void PrepareDefaultSubject(AuditEvent auditEvent) /// public virtual async Task LogEventAsync(AuditEvent auditEvent, Action loggerOptions = default) { + if (!_auditLoggerOptions.Enabled) + { + return; + } + await PrepareEventAsync(auditEvent, loggerOptions); foreach (var sink in Sinks) diff --git a/src/Skoruba.AuditLogging/Skoruba.AuditLogging.csproj b/src/Skoruba.AuditLogging/Skoruba.AuditLogging.csproj index 7db9060..0cb92d5 100644 --- a/src/Skoruba.AuditLogging/Skoruba.AuditLogging.csproj +++ b/src/Skoruba.AuditLogging/Skoruba.AuditLogging.csproj @@ -1,8 +1,8 @@  - netcoreapp3.1 - 1.0.0 + net6.0 + 1.1.0 Simple audit logging for .NET Core with EntityFramework Core support https://github.com/skoruba/AuditLogging @@ -25,9 +25,9 @@ - - - + + + From babc50a564553e658ad9d4ca9236ddd402f5ae1f Mon Sep 17 00:00:00 2001 From: janskoruba Date: Tue, 21 Dec 2021 21:28:48 +0100 Subject: [PATCH 2/2] Update README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d1fdab..9592569 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ # 🕊️ Skoruba.AuditLogging > Simple audit logging for .NET Core with EntityFramework Core support -**This project is ported to .NET Core 3.1.** 🚀 +**This project is ported to .NET 6.** 🚀 # How to install ```ps -dotnet add package Skoruba.AuditLogging.EntityFramework --version 1.0.0 +dotnet add package Skoruba.AuditLogging.EntityFramework --version 1.1.0 ``` # How to use it @@ -18,6 +18,7 @@ dotnet add package Skoruba.AuditLogging.EntityFramework --version 1.0.0 ```csharp services.AddAuditLogging(options => { + options.Enabled = true; options.UseDefaultSubject = true; options.UseDefaultAction = true; })