NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public class LoggerConfiguration
{
readonly List<ILogEventSink> _logEventSinks = new List<ILogEventSink>();
readonly List<ILogEventSink> _auditSinks = new List<ILogEventSink>();
readonly List<ILogEventEnricher> _enrichers = new List<ILogEventEnricher>();
readonly List<ILogEventFilter> _filters = new List<ILogEventFilter>();
readonly List<Type> _additionalScalarTypes = new List<Type>();
readonly HashSet<Type> _additionalDictionaryTypes = new HashSet<Type>();
readonly List<IDestructuringPolicy> _additionalDestructuringPolicies = new List<IDestructuringPolicy>();

readonly Dictionary<string, LoggingLevelSwitch> _overrides = new Dictionary<string, LoggingLevelSwitch>();
LogEventLevel _minimumLevel = LogEventLevel.Information;
LoggingLevelSwitch? _levelSwitch;
int _maximumDestructuringDepth = 10;
int _maximumStringLength = int.MaxValue;
int _maximumCollectionCount = int.MaxValue;
bool _loggerCreated;

// Property to store DealID conditionally
public string? DealID { get; set; }

public LoggerConfiguration()
{
WriteTo = new LoggerSinkConfiguration(this, s => _logEventSinks.Add(s));
Enrich = new LoggerEnrichmentConfiguration(this, e => _enrichers.Add(e));
}

public LoggerSinkConfiguration WriteTo { get; internal set; }

public LoggerAuditSinkConfiguration AuditTo => new LoggerAuditSinkConfiguration(this, s => _auditSinks.Add(s));

public LoggerMinimumLevelConfiguration MinimumLevel
{
get
{
return new LoggerMinimumLevelConfiguration(this,
l =>
{
_minimumLevel = l;
_levelSwitch = null;
},
sw => _levelSwitch = sw,
(s, lls) => _overrides[s] = lls);
}
}

public LoggerEnrichmentConfiguration Enrich { get; internal set; }

public LoggerFilterConfiguration Filter => new LoggerFilterConfiguration(this, f => _filters.Add(f));

public LoggerDestructuringConfiguration Destructure
{
get
{
return new LoggerDestructuringConfiguration(
this,
_additionalScalarTypes.Add,
type => _additionalDictionaryTypes.Add(type),
_additionalDestructuringPolicies.Add,
depth => _maximumDestructuringDepth = depth,
length => _maximumStringLength = length,
count => _maximumCollectionCount = count);
}
}

public LoggerSettingsConfiguration ReadFrom => new LoggerSettingsConfiguration(this);

public Logger CreateLogger()
{
if (_loggerCreated) throw new InvalidOperationException("CreateLogger() was previously called and can only be called once.");

_loggerCreated = true;

ILogEventSink? sink = null;
if (_logEventSinks.Count > 0)
sink = new SafeAggregateSink(_logEventSinks);

var auditing = _auditSinks.Any();
if (auditing)
{
sink = new AggregateSink(sink == null ? _auditSinks : new[] { sink }.Concat(_auditSinks));
}

sink ??= new SafeAggregateSink(Array.Empty<ILogEventSink>());

if (_filters.Any())
{
sink = new FilteringSink(sink, _filters, auditing);
}

var converter = new PropertyValueConverter(
_maximumDestructuringDepth,
_maximumStringLength,
_maximumCollectionCount,
_additionalScalarTypes,
_additionalDictionaryTypes,
_additionalDestructuringPolicies,
auditing);
var processor = new MessageTemplateProcessor(converter);

var enricher = _enrichers.Count switch
{
0 => new EmptyEnricher(),
1 => _enrichers[0],
_ => new SafeAggregateEnricher(_enrichers)
};

// Conditionally set DealID
string? dealID = DealID;

// Create an enricher that includes DealID if it's not null or empty
if (!string.IsNullOrEmpty(dealID))
{
enricher = new SafeAggregateEnricher(new List<ILogEventEnricher> { enricher, new PropertyEnricher("DealID", dealID, true) });
}

LevelOverrideMap? overrideMap = null;
if (_overrides.Count != 0)
{
overrideMap = new LevelOverrideMap(_overrides, _minimumLevel, _levelSwitch);
}

var disposableSinks = _logEventSinks
.Concat(_auditSinks)
.Where(s => s is IDisposable)
.ToArray();

void Dispose()
{
foreach (var disposable in disposableSinks)
{
(disposable as IDisposable)?.Dispose();
}
}

return new Logger(
processor,
_levelSwitch != null ? LevelAlias.Minimum : _minimumLevel,
_levelSwitch,
sink,
enricher,
Dispose,
overrideMap);
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.