Skip to content

Commit

Permalink
Made 'SkipSaving' obsolete. Added 'SkipSavingLogToApplicationDatabse'…
Browse files Browse the repository at this point in the history
… property. Renamed 'SkipSavingToSerilog' to 'SkipSavingLogToSerilog'
  • Loading branch information
Bilal Fazlani committed Mar 11, 2016
1 parent 429a381 commit 11e3afe
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
9 changes: 8 additions & 1 deletion SampleLogMaker/Models/DbContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ public ApplicationDbContext()
//or any serilog sink you want
.CreateLogger();

AddLogger(logger);
AddLogger(logger, "@{log}", loginfo=> new object[] {loginfo});

//stop saving audit logs to applicaiton database
OnAuditLogGenerated += (sender, args) =>
{
args.SkipSaving = true;
args.SkipSavingLogToSerilog = false; // <-- this is false by default
};
}

public DbSet<Blog> Blogs { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions TrackerEnabledDbContext.Common/CoreTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DbEntityEntry ent in
_context.AuditLog.Add(record);
}

if (!arg.SkipSavingToSerilog)
if (!arg.SkipSavingLogToSerilog)
{
LogToLogger(arg.Log);
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public void AuditAdditions(object userName, IEnumerable<DbEntityEntry> addedEntr
_context.AuditLog.Add(record);
}

if (!arg.SkipSavingToSerilog)
if (!arg.SkipSavingLogToSerilog)
{
LogToLogger(arg.Log);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using TrackerEnabledDbContext.Common.Models;
using System;
using TrackerEnabledDbContext.Common.Models;

namespace TrackerEnabledDbContext.Common.EventArgs
{
Expand All @@ -14,8 +15,16 @@ public AuditLogGeneratedEventArgs(AuditLog log, object entity)

public object Entity { get; internal set; }

public bool SkipSaving { get; set; } = false;

public bool SkipSavingToSerilog { get; set; } = false;
[Obsolete("This property is Obsolete. Please use `SkipSavingLogToApplicationDatabase`. This property will be removed in future versions")]
public bool SkipSaving
{
get { return SkipSavingLogToApplicationDatabase; }
set { SkipSavingLogToApplicationDatabase = value; }
}

public bool SkipSavingLogToApplicationDatabase { get; set; } = false;

public bool SkipSavingLogToSerilog { get; set; } = false;
}
}
4 changes: 2 additions & 2 deletions TrackerEnabledDbContext.Common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("3.5.2.0")]
[assembly: AssemblyFileVersion("3.5.2.0")]
[assembly: AssemblyVersion("3.5.15.0")]
[assembly: AssemblyFileVersion("3.5.15.0")]
4 changes: 2 additions & 2 deletions TrackerEnabledDbContext.Identity/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("3.5.2.0")]
[assembly: AssemblyFileVersion("3.5.2.0")]
[assembly: AssemblyVersion("3.5.15.0")]
[assembly: AssemblyFileVersion("3.5.15.0")]
4 changes: 2 additions & 2 deletions TrackerEnabledDbContext/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("3.5.2.0")]
[assembly: AssemblyFileVersion("3.5.2.0")]
[assembly: AssemblyVersion("3.5.15.0")]
[assembly: AssemblyFileVersion("3.5.15.0")]

0 comments on commit 11e3afe

Please sign in to comment.