public override void WriteLine(string message) { try { _logger.Log(_debug ? LogLevel.Debug : LogLevel.Trace, message); } catch (Exception e) { Bugs.LastResortEmergencyLog(e); } }
public static void Log(this ILogger logger, LogMessage message) { if (logger != null) { try { logger.Log(message); } catch (Exception e) { Bugs.LastResortEmergencyLog(message); Bugs.LastResortEmergencyLog(e); } } }
protected AsyncAppender() { _task = Task.Run(async() => { while (!IsDisposed) { try { var taken = await _queue.TakeAsync(DisposeToken); if (taken.End) { break; } var tuple = taken.Value; if (tuple.Item1 == null && tuple.Item2 == null) { await FlushAsync(DisposeToken); } else { await AppendAsync(tuple.Item1, tuple.Item2, DisposeToken); if (_flushImmediately) { await FlushAsync(CancellationToken.None); // we flush even cancellation (which is disposal in fact) is in progress } } } catch (OperationCanceledException) { } } catch (Exception e) { Bugs.LastResortEmergencyLog(e); } });