Add Trace log level.
Created by: WamWooWam
Summary
Adds a trace log level that writes all incoming and outgoing WebSocket messages to the DebugLogger.
Details
In the past, we've had one or two recurring bugs that could've been fixed much more easily if we could view the WebSocket traffic going to and from Discord. Previously, in order to do this we'd have to use Fiddler or Wireshark, and disable socket compression, which isn't a great solution. This PR adds a new log level called Trace
, which outputs all WebSocket traffic to the DebugLogger.
Changes proposed
- Add
LogLevel.Trace
. - Move all instances of
BaseWebSocketClient#SendMessage
into wrapper functions that also write the payload toDiscordClient#DebugLogger
. - Add a warning to discourage use of
LogLevel.Trace
outside of specific debugging scenarios.
Notes
I'm not too happy with the wrapper functions, but I also don't see a great way around the problem.
I also don't sanitise output in any way, to do so would add an extra JSON Deserialization step, hurting performance more and adding an extra layer to debug, so it's almost certain the logged data will contain personal information.
Would it not also be beneficial to include the response payloads from REST requests? Just in case? They're less likely to cause problems, but might be useful nonetheless.