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,20 +111,31 @@ namespace BirthdayBot
private Task Client_Log(LogMessage arg) private Task Client_Log(LogMessage arg)
{ {
// Suppress certain messages // Suppress certain messages
if (arg.Message.StartsWith("Unknown Dispatch ")) return Task.CompletedTask; if (arg.Message != null)
switch (arg.Message) // Connection status messages replaced by ShardManager's output
{ {
case "Connecting": if (arg.Message.StartsWith("Unknown Dispatch ")) return Task.CompletedTask;
case "Connected": switch (arg.Message) // Connection status messages replaced by ShardManager's output
case "Ready": {
case "Failed to resume previous session": case "Connecting":
case "Resumed previous session": case "Connected":
case "Disconnecting": case "Ready":
case "Disconnected": case "Failed to resume previous session":
case "Resumed previous session":
case "Disconnecting":
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;