public static async Task <T> WithinMonitoredScopeAsync <T>( this ILogger logger, EventId eventId, LogSource source, Func <Task <T> > body, ILogSeverity severity = null ) { using var monitoredScope = new MonitoredScope(logger, severity ?? CommonLogSeverity.Information, eventId, DateTime.UtcNow, source); return(await body()); }
public MonitoredScope( ILogger logger, ILogSeverity severity, EventId eventId, DateTime start, LogSource source) { Logger = logger; Severity = severity; EventId = eventId; Start = start; Source = source; }
public LogEntry( ILogSeverity severity, DateTime moment, LogSource source, Guid sequenceId, EventId eventId, Object data, IDictionary <String, Object> metadata, Exception exception) { Severity = severity ?? throw new ArgumentNullException(nameof(severity), $"'{nameof(severity)}' is not allowed to be null."); Moment = moment; Source = source ?? throw new ArgumentNullException(nameof(source), $"'{nameof(source)}' is not allowed to be null."); SequenceId = sequenceId; EventId = eventId; Data = data ?? throw new ArgumentNullException(nameof(data), $"'{nameof(data)}' is not allowed to be null."); Metadata = metadata ?? throw new ArgumentNullException(nameof(metadata), $"'{nameof(metadata)}' is not allowed to be null."); Exception = exception; }
public static void Log( this ILogger logger, ILogSeverity severity, EventId eventId, Object data, Exception exception = null, LogSource source = null, Guid?sequenceId = null, IDictionary <String, Object> metadata = null ) => logger.Log(new LogEntry( severity, DateTime.UtcNow, source ?? DefaultSource, sequenceId ?? DefaultSequenceId, eventId, data, metadata ?? new Dictionary <String, Object>(), exception ));
public LogEntry With( ILogSeverity severity = null, DateTime?moment = null, LogSource source = null, Guid?sequenceId = null, EventId?eventId = null, Object data = null, IDictionary <String, Object> metadata = null, Exception exception = null ) => new LogEntry( severity ?? Severity, moment ?? Moment, source ?? Source, sequenceId ?? SequenceId, eventId ?? EventId, data ?? Data, metadata ?? Metadata, exception ?? Exception );
public ILogSeverity Parse(String text, ILogSeverity defaultValue) => Parse(text) ?? defaultValue;
public TriggerableLevelFilter(ILogSeverity startLevel, ILogSeverity triggerLevel, ILogSeverity targetLevel) : this(startLevel.Value, triggerLevel.Value, targetLevel.Value) { // empty proxy constructor }