Ejemplo n.º 1
0
        protected override async Task AppendAsync(ILogger logger, LogMessage message, CancellationToken ct)
        {
            if (IsDisposed || !Check())
            {
                return;
            }
            try
            {
                var line = logger.Formatter.Format(logger, message);
                await Writer.WriteLineAsync(line);

                if (message.Exception != null)
                {
                    await Writer.WriteLineAsync(message.Exception.ToString());
                }
            }
            catch (ThreadAbortException)
            {
                // not sure why but happens sometimes in tests
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception e)
            {
                // this must be something serious.
                Bugs.Break(e);
            }
        }
Ejemplo n.º 2
0
 protected override async Task FlushAsync(CancellationToken ct)
 {
     try
     {
         if (IsDisposed || Writer == null)
         {
             return;
         }
         var writer = Writer;
         if (writer != null)
         {
             await Writer.FlushAsync();
         }
     }
     catch (OperationCanceledException)
     {
     }
     catch (Exception e)
     {
         Bugs.Break(e);
     }
 }