Refactor logging
This commit is contained in:
1 parent
b930588556
commit
c907ec0f44
67 files changed
+2039
-627
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Serilog;
|
||||
using Serilog.Configuration;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace VocaluxeLib.Log.Enricher
|
||||
{
|
||||
public static class WithTimeStampFromStartExtension
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static LoggerConfiguration WithTimeStampFromStart(this LoggerEnrichmentConfiguration enrich)
|
||||
{
|
||||
return enrich.With(new CTimeStampFromStartEnricher());
|
||||
}
|
||||
|
||||
private class CTimeStampFromStartEnricher : ILogEventEnricher
|
||||
{
|
||||
private readonly DateTimeOffset _Start = DateTimeOffset.Now;
|
||||
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory lepf)
|
||||
{
|
||||
logEvent.AddPropertyIfAbsent(
|
||||
lepf.CreateProperty("TimeStampFromStart", logEvent.Timestamp - _Start));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user