public async Task WriteAsync(ILogItem item) { if (!LevelAllowed.HasFlag(item.Level)) { return; } var msg = string.Format("{0}\r\nMachine Name: {1} [{2}]\r\nAplicationName: {3}\r\nMessage: {4}", item.Timestamp.ToString("dd/MM/yyyy HH:mm:ss"), item.MachineName, item.EnvironmentName, item.ApplicationName, item.Message); if (item.Exception != null) { if (!string.IsNullOrEmpty(item.Exception.ExceptionType)) { msg += "\r\nException: " + item.Exception.ExceptionType; } if (SendStackTrace && !string.IsNullOrEmpty(item.Exception?.StackTrace)) { msg += "\r\nStack Trace: " + item.Exception.StackTrace; } if (item.Exception.StackTrace.Contains("TelegramBotTransport.<<ConnectAsync>")) { return; } } await Bot.SendTextMessageToTrackedChatsAsync(msg).ConfigureAwait(false); }
public Task WriteAsync(ILogItem item) { if (!LevelAllowed.HasFlag(item.Level) || item.Message.Contains("SMTPERROR")) { return(Task.CompletedTask); } lock (_buffer) _buffer.Add(item); if (_waiting) { return(Task.CompletedTask); } _waiting = true; Task.Delay(BufferTimeoutInSeconds * 1000).ContinueWith(t => { SendEmail(); }); return(Task.CompletedTask); }