Skip to content

Commit

Permalink
Replace usages of Console.WriteLine() with proper logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Sep 11, 2024
1 parent eb12c77 commit 899646f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Events/ErrorEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ await e.Context.RespondAsync(
};
embed.AddField("Message", ex.Message);

Console.WriteLine(
$"{ex.GetType()} occurred when {UserInfoHelpers.GetFullUsername(e.Context.User)} used {e.Command!.QualifiedName}: {ex.Message}\n{ex.StackTrace}");
Program.Discord.Logger.LogError(Program.BotEventId, "An exception occurred when processing a CommandsNext command!"
+ "\n{exType} occurred when {username} used {commandName}: {exMessage}\n{exStackTrace}", ex.GetType(), UserInfoHelpers.GetFullUsername(e.Context.User), e.Command!.QualifiedName, ex.Message, ex.StackTrace);

// System.ArgumentException
if (ex.GetType().ToString() == "System.ArgumentException")
Expand Down
4 changes: 2 additions & 2 deletions Events/MessageEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ public static async Task ThrowMessageException(Exception ex, DiscordMessage mess
};
embed.AddField("Message", $"{ex.Message}");

Console.WriteLine(
$"{ex.GetType()} occurred when processing a message {(isEdit ? "edit" : "create")} event: {ex.Message}\n{ex.StackTrace}");
Program.Discord.Logger.LogError(Program.BotEventId, "An exception occurred when processing a message {eventType} event!"
+ "\n{exType}: {exMessage}\n{exStackTrace}", isEdit ? "edit" : "create", ex.GetType(), ex.Message, ex.StackTrace);

await Program.HomeChannel.SendMessageAsync(embed);
}
Expand Down
4 changes: 2 additions & 2 deletions Helpers/ReminderHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public static async Task LogReminderErrorAsync(DiscordChannel logChannel, Except
errorEmbed.AddField("Message", $"{ex.Message}");
errorEmbed.AddField("Stack Trace", $"```\n{ex.StackTrace}\n```");

Console.WriteLine(
$"{ex.GetType()} occurred when checking reminders: {ex.Message}\n{ex.StackTrace}");
Program.Discord.Logger.LogError(Program.BotEventId, "An exception occurred when checking reminders!"
+ "\n{exType}: {exMessage}\n{exStackTrace}", ex.GetType(), ex.Message, ex.StackTrace);

await logChannel.SendMessageAsync(errorEmbed);
}
Expand Down
4 changes: 2 additions & 2 deletions Tasks/ActivityTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ await Program.Db.StringSetAsync("customStatusLastUpdated",
};
embed.AddField("Message", ex.Message);

Console.WriteLine(
$"{ex.GetType()} occurred while processing a custom status message: {ex.Message}\n{ex.StackTrace}");
Program.Discord.Logger.LogError(Program.BotEventId, "An exception occurred when processing a custom status message!"
+ "\n{exType}: {exMessage}\n{exStackTrace}", ex.GetType(), ex.Message, ex.StackTrace);

await Program.HomeChannel.SendMessageAsync(embed);
}
Expand Down

0 comments on commit 899646f

Please sign in to comment.