public virtual void TraceData(TraceEventType eventType, int id, object data)
 {
     Execute(() =>
     {
         var args = enricher.Enrich(new[] { data }, true);
         traceSource.TraceData(eventType, id, args);
     });
 }
Beispiel #2
0
        public override void OnEnd(LogRecord data)
        {
            var level = 0;

            switch (data.LogLevel)
            {
            case LogLevel.Critical:
                level = 21;
                break;

            case LogLevel.Debug:
                level = 5;
                break;

            case LogLevel.Error:
                level = 17;
                break;

            case LogLevel.Information:
                level = 9;
                break;

            case LogLevel.Trace:
                level = 1;
                break;

            case LogLevel.Warning:
                level = 13;
                break;
            }

            var attributes = new Dictionary <string, object>();
            var message    = _enricher.Enrich(attributes, data.FormattedMessage, data.State ?? data.StateValues, data.Exception, attr =>
            {
                data.ForEachScope((scope, a) =>
                {
                    foreach (var kvp in scope)
                    {
                        a[kvp.Key] = kvp.Value;
                    }
                }, attr);
            });

            _processor.ProcessLog(level, data.Timestamp, message, attributes, data.SpanId.ToString(), data.TraceId.ToString());
        }