예제 #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);
     }
 }
예제 #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));
        }
예제 #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)))));
 }
예제 #5
0
 LogEventProperty CreateProperty(string name, object value)
 {
     return(LogEventPropertyFactory.SafeCreate(name, CreatePropertyValue(value)));
 }
예제 #6
0
 public ScalarPropertyEnricher(string name, object scalarValue)
 {
     _property = LogEventPropertyFactory.SafeCreate(name, new ScalarValue(scalarValue));
 }