Beispiel #1
0
 public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
 {
     foreach (var property in logEvent.Properties)
     {
         var updated = LogEventPropertyFactory.SafeCreate(property.Key, Visit(null, property.Value));
         logEvent.AddOrUpdateProperty(updated);
     }
 }
Beispiel #2
0
        static IEnumerable <LogEventProperty> GetLogEventProperties(IDictionary <string, object> properties, string remainder, string level)
        {
            var payload = properties
                          .Where(p => !ReifiedProperties.IsReifiedProperty(p.Key))
                          .Concat(new[] { KeyValuePair.Create(SurrogateLevelProperty.PropertyName, (object)level) })
                          .Select(p => LogEventPropertyFactory.SafeCreate(p.Key, new ScalarValue(p.Value)));

            if (remainder != null)
            {
                payload = payload.Concat(new[]
                {
                    LogEventPropertyFactory.SafeCreate("@unmatched", new ScalarValue(remainder))
                });
            }
            return(payload);
        }
        public async Task <ReadResult> TryReadAsync()
        {
            var result = await _inner.TryReadAsync();

            if (result.LogEvent == null)
            {
                return(result);
            }

            var evt = new LogEvent(
                result.LogEvent.Timestamp,
                result.LogEvent.Level,
                result.LogEvent.Exception,
                _messageTemplate,
                result.LogEvent.Properties.Select(kv => LogEventPropertyFactory.SafeCreate(kv.Key, kv.Value)));

            return(new ReadResult(evt, result.IsAtEnd));
        }
Beispiel #4
0
 protected override LogEventPropertyValue VisitStructureValue(object state, StructureValue structure)
 {
     return(new StructureValue(structure.Properties.Select(p =>
                                                           LogEventPropertyFactory.SafeCreate(p.Name, Visit(null, p.Value)))));
 }
Beispiel #5
0
 LogEventProperty CreateProperty(string name, object value)
 {
     return(LogEventPropertyFactory.SafeCreate(name, CreatePropertyValue(value)));
 }
 public ScalarPropertyEnricher(string name, object scalarValue)
 {
     _property = LogEventPropertyFactory.SafeCreate(name, new ScalarValue(scalarValue));
 }