protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events) { if (_switcher.CurrentMode == Mode.Fallback) { foreach (var logEvent in events) { _fallbackSink.Emit(logEvent); } return; } try { await _kafkaSink.LogEntriesAsync(events); } catch (Exception ex) { _switcher.SwitchToFallback(ex); foreach (var logEvent in events) { _fallbackSink.Emit(logEvent); } } }
public void Emit(LogEvent logEvent) { if (_condition(logEvent)) { _wrapped.Emit(logEvent); } }
public void Emit(LogEvent logEvent) { if (logEvent.Level >= filteredLevel || Keyboard.PrimaryDevice.IsKeyToggled(Key.Scroll)) { innerSink.Emit(logEvent); } }
public void Emit(LogEvent logEvent) { var timestamp = _getTimestamp(logEvent); var surrogate = new LogEvent(timestamp, logEvent.Level, logEvent.Exception, logEvent.MessageTemplate, logEvent.Properties.Select(kv => new LogEventProperty(kv.Key, kv.Value))); _target.Emit(surrogate); }
public void AddSink(ILogEventSink sink) { foreach (LogEvent previousEvent in _events) { sink.Emit(previousEvent); } _sinks.Enqueue(sink); }
private void WriteEventsToSinks() { var copyOfEvents = _eventEntries.ToArray(); foreach (var entry in copyOfEvents.Where(e => e.WriteToSink)) { _sink.Emit(entry.Event); } }
public void Emit(LogEvent logEvent) { if (logEvent == null) { throw new ArgumentNullException("logEvent"); } var copy = new LogEvent(logEvent.Timestamp, logEvent.Level, logEvent.Exception, logEvent.MessageTemplate, logEvent.Properties.Values); _copyToSink.Emit(copy); }
public void Emit(LogEvent logEvent) { foreach (var logEventFilter in _filters) { if (!logEventFilter.IsEnabled(logEvent)) { return; } } _sink.Emit(logEvent); }
public void Emit(LogEvent logEvent) { // If you like this, you might like Serilog.Expressions even better :) // https://github.com/serilog/serilog-expressions var newTimestamp = logEvent.Timestamp.AddHours(-5); var newLogEvent = new LogEvent(newTimestamp, logEvent.Level, logEvent.Exception, logEvent.MessageTemplate, logEvent.Properties.Select(p => new LogEventProperty(p.Key, p.Value))); _targetSink.Emit(newLogEvent); }
public void Emit(LogEvent logEvent) { if (logEvent == null) { throw new ArgumentNullException(nameof(logEvent)); } if ((int)logEvent.Level < (int)_levelSwitch.MinimumLevel) { return; } _sink.Emit(logEvent); }
public void Emit(LogEvent logEvent) { if (logEvent == null) { throw new ArgumentNullException("logEvent"); } if (logEvent.Level < _restrictedMinimumLevel) { return; } _sink.Emit(logEvent); }
void Pump() { try { foreach (var next in _queue.GetConsumingEnumerable()) { _pipeline.Emit(next); } } catch (Exception ex) { SelfLog.WriteLine("{0} fatal error in worker thread: {1}", typeof(BackgroundWorkerSink), ex); } }
void Dispatch(LogEvent logEvent) { // The enricher may be a "safe" aggregate one, but is most commonly bare and so // the exception handling from SafeAggregateEnricher is duplicated here. try { _enricher.Enrich(logEvent, _messageTemplateProcessor); } catch (Exception ex) { SelfLog.WriteLine("Exception {0} caught while enriching {1} with {2}.", ex, logEvent, _enricher); } _sink.Emit(logEvent); }
void Dispatch(LogEvent logEvent) { foreach (var enricher in _enrichers) { try { enricher.Enrich(logEvent, _messageTemplateProcessor); } catch (Exception ex) { SelfLog.WriteLine("Exception {0} caught while enriching {1} with {2}.", ex, logEvent, enricher); } } _sink.Emit(logEvent); }
public void Emit(LogEvent logEvent) { try { foreach (var logEventFilter in _filters) { if (!logEventFilter.IsEnabled(logEvent)) { return; } } _sink.Emit(logEvent); } catch (Exception ex) { SelfLog.WriteLine("Caught exception {0} while applying filters.", ex); } }
public void Emit(LogEvent logEvent) { ScanForDeadRequests(); LogEventPropertyValue requestIdValue; if (logEvent.Properties.TryGetValue(_requestIdProperty, out requestIdValue)) { string requestId = requestIdValue.ToString(null, null).Replace("\"", string.Empty); var buffer = GetOrCreateRequestBuffer(requestId); buffer.LogEvent(logEvent); } else { if (_eventLevel.IsSatisifedBy(logEvent.Level)) { _sink.Emit(logEvent); } } }
void Pump() { try { foreach (var next in _queue.GetConsumingEnumerable()) { try { _wrappedSink.Emit(next); } catch (Exception ex) { SelfLog.WriteLine("{0} failed to emit event to wrapped sink: {1}", typeof(BackgroundWorkerSink), ex); } } } catch (Exception fatal) { SelfLog.WriteLine("{0} fatal error in worker thread: {1}", typeof(BackgroundWorkerSink), fatal); } }
/// <inheritdoc /> /// <summary> /// Emit the provided log event to the sink. /// </summary> /// <param name="logEvent"> The log event to write. </param> /// <remarks> /// Events that come in out-of-order (e.g. around the rollovers) may end up written to a /// later file than their timestamp would indicate. /// </remarks> public void Emit(LogEvent logEvent) { if (logEvent == null) { throw new ArgumentNullException(nameof(logEvent)); } lock (_syncRoot) { if (_isDisposed) { throw new ObjectDisposedException("The rolling log file has been disposed."); } AlignCurrentFileTo(logEvent); // If the file was unable to be opened on the last attempt, it will remain null until // the next checkpoint passes, at which time another attempt will be made to open it. _currentFile?.Emit(logEvent); } }
private async Task PumpAsync() { try { while (await _channel.Reader.WaitToReadAsync()) { var logEvent = await _channel.Reader.ReadAsync(); try { _wrappedSink.Emit(logEvent); } catch (Exception ex) { SelfLog.WriteLine("{0} failed to emit event to wrapped sink: {1}", typeof(BackgroundWorkerSink), ex); } } } catch (Exception fatal) { SelfLog.WriteLine("{0} fatal error in worker thread: {1}", typeof(BackgroundWorkerSink), fatal); } }
public void Emit(LogEvent logEvent) { _sink.Emit(logEvent); }
public void Emit <T>(Event <T> evt) { var nativeEvent = _mapper.Map(evt); _sink.Emit(nativeEvent); }
public void Emit(LogEvent logEvent) { Emitted.Add(logEvent); _sink.Emit(logEvent); }
/// <inheritdoc /> public void Emit(LogEvent logEvent) { _sink.Emit(logEvent); Interlocked.Exchange(ref _flushRequired, 1); }
/// <inheritdoc /> public void Emit(LogEvent logEvent) => sink.Emit(logEvent);