Fix null log messages being dropped

This commit is contained in:
Noi 2020-10-29 00:56:46 -07:00
parent 8e6da3c8d0
commit 14d3e926a0

View file

@ -111,6 +111,8 @@ namespace BirthdayBot
private Task Client_Log(LogMessage arg) private Task Client_Log(LogMessage arg)
{ {
// Suppress certain messages // Suppress certain messages
if (arg.Message != null)
{
if (arg.Message.StartsWith("Unknown Dispatch ")) return Task.CompletedTask; if (arg.Message.StartsWith("Unknown Dispatch ")) return Task.CompletedTask;
switch (arg.Message) // Connection status messages replaced by ShardManager's output switch (arg.Message) // Connection status messages replaced by ShardManager's output
{ {
@ -121,10 +123,19 @@ namespace BirthdayBot
case "Resumed previous session": case "Resumed previous session":
case "Disconnecting": case "Disconnecting":
case "Disconnected": case "Disconnected":
case "WebSocket connection was closed":
return Task.CompletedTask;
}
if (arg.Message == "Heartbeat Errored")
{
// Replace this with a custom message; do not show stack trace
Log("Discord.Net", $"{arg.Severity}: {arg.Message} - {arg.Exception.Message}");
return Task.CompletedTask; return Task.CompletedTask;
} }
Log("Discord.Net", $"{arg.Severity}: {arg.Message}"); Log("Discord.Net", $"{arg.Severity}: {arg.Message}");
}
if (arg.Exception != null) Log("Discord.Net", arg.Exception.ToString()); if (arg.Exception != null) Log("Discord.Net", arg.Exception.ToString());
return Task.CompletedTask; return Task.CompletedTask;