public static ILogScope BeginScope(this ILogger logger, out object correlationId) { var scope = LogScope.Push(); scope.WithCorrelationId(out correlationId); return(scope); }
public static IEnumerable <LogScope> Flatten(this LogScope scope) { var current = scope; while (current != null) { yield return(current); current = current.Parent; } }
internal static Log Render(this Log log, IEnumerable <ILogAttachment> attachments) { // Recreate the log with all properties and compute them. // Get get last added attachment. This allows us to override them within a scope. attachments = attachments .Concat(LogScope.Attachments()) .GroupBy(a => a.Name) .Select(g => g.Last()); var attachmentProperties = attachments.Select(attachment => new KeyValuePair <SoftString, object>(attachment.Name, attachment)); var properties = log.Concat(attachmentProperties); log = new Log().AddRangeSafely(properties); return(log.Compute(log)); }
public static LogScope BeginScope(this ILogger logger, SoftString name, object state, Action <Log> logAction) { return(LogScope.Push(name, Reflection.GetProperties(state), logAction)); }
public static ILogScope BeginScope(this ILogger logger) { return(LogScope.Push().WithCorrelationId()); }
public static ILogScope WithCorrelationId(this ILogScope scope, out object correlationId) { return(scope.WithCorrelationId(correlationId = LogScope.NewCorrelationId())); }