Exemplo n.º 1
0
        public static ILogScope BeginScope(this ILogger logger, out object correlationId)
        {
            var scope = LogScope.Push();

            scope.WithCorrelationId(out correlationId);
            return(scope);
        }
Exemplo n.º 2
0
        public static IEnumerable <LogScope> Flatten(this LogScope scope)
        {
            var current = scope;

            while (current != null)
            {
                yield return(current);

                current = current.Parent;
            }
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 public static LogScope BeginScope(this ILogger logger, SoftString name, object state, Action <Log> logAction)
 {
     return(LogScope.Push(name, Reflection.GetProperties(state), logAction));
 }
Exemplo n.º 5
0
 public static ILogScope BeginScope(this ILogger logger)
 {
     return(LogScope.Push().WithCorrelationId());
 }
Exemplo n.º 6
0
 public static ILogScope WithCorrelationId(this ILogScope scope, out object correlationId)
 {
     return(scope.WithCorrelationId(correlationId = LogScope.NewCorrelationId()));
 }