Beispiel #1
0
 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());
 }
Beispiel #2
0
 public MonitoredScope(
     ILogger logger,
     ILogSeverity severity,
     EventId eventId,
     DateTime start,
     LogSource source)
 {
     Logger   = logger;
     Severity = severity;
     EventId  = eventId;
     Start    = start;
     Source   = source;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 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
                ));
Beispiel #5
0
 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
 }