delta-client
delta-client copied to clipboard
Add a way to view logs in-app
This would be a super useful feature for troubleshooting. It would probably make the most sense to have the option located in the menu bar and the troubleshooting menu (#24 , will be finished by @AlbertoSamele soon). It'd probably be best if it opened in a separate window so that the logs can be viewed while using the app. It should also have an option to auto scroll down when new messages are logged. And being able to filter by verbosity level would be handy too.
To implement this feature, you'll probably want to create a custom log handler that saves logs into a buffer (with a limit on the number of logs stored at any given time). For optimisation reasons the buffer will probably have to be a ring buffer, but once implemented regularly we can see whether it's actually required or not. The extra window can probably be added to the body of DeltaClientApp inside an if statement that checks whether logs should be shown. The toggle can just be a boolean state variable on DeltaClientApp and the way users will toggle it can probably just be a menu option (with some sort of keyboard shortcut set for quick access). Hopefully that helps clear a few things up, feel free to suggest a better way or to ask me for clarification (on the Discord server).
To implement this I first switched over to the Puppy logging library which has support for file rotation logging by default. Delta Client now logs to ~/Library/Application Support/dev.stackotter.delta-client/logs/delta-client.log.
Then I added a View > Logs item to the menu bar and a View logs button to the troubleshooting view (in settings). These both open the current log file in macOS's built-in Console app which auto scrolls to the bottom of the logs and updates them live as the file is updated. This isn't perfect because the logs aren't perfectly realtime (because of the batching that Puppy does for performance), but I don't see any use case where the debug logs need to be perfectly smooth. The only downside is not being able to filter by log level, but that's not super important for now.