-
-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add logger to Zellij #592
Conversation
We add log4rs create for logging across Zellij. Additionally, we capture `stderr` output from plugins and log it the same log file as other Zellij logs.
This looks super cool! I'm still a bit homeless at the moment, as I'm between places and moving, but I'll try to give this a look either today or tomorrow! thanks so much for doing this! Is there anything in particular you'd like me to look at or think about? |
Hey, thanks! For now this is still a bit of WIP, but I think that the general mechanism for plugin logs will not change. Neither will the logging crate (unless you or other contributors suggest otherwise). As for the initial review, feel free to have a look at it but please remember that it's a bit crude at the moment and might change a bit. I will try to finish it as fast as possible and ping on discord when it's ready for a proper, detailed review. 😃. I added a small guide in the initial comment to make the review as easy as possible. |
…ugin messages. Basic logging from plugins works now.
…derstand it without looking into log4rs docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all of your hard work! This is looking great! I left a couple of comments as a first pass.
The main things I think we should look into are making the plugin log-lines fit with the rest of the log lines (adding a date at least), and writing to the proper Zellij log directory in /tmp
.
Overall, I'm very pleased with this!
…. Add plugin_id to plugin log. Move logger init from file to in-code initialization and change logging file to zellij directory. Change format of timestamp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it! I left a couple of small comments for you to address if you'd like, but I'm happy with merging this! Feel free to do any final cleanup (I'm not sure if you want to keep all of the test messages in?) and merge when ready!
@qepasa Let me know if you need any help with merge conflicts! I think it's just been a bump in the crate versions though, so it shouldn't be too difficult :) |
@TheLostLambda Done 😃 Also, changed the |
@qepasa Looks stellar! Thank you for all of your hard work on this! It's been lovely working with you and I'm excited to see you around more! I'll merge it now and update the changelog! |
We add log4rs create for logging across Zellij. Additionally, we capture
stderr
output from plugins and log it the same log file as otherZellij logs.
We set up the logger in
zellij-utils/src/logging.rs
. The logger parsesconfiguration from
zellij-utils/assets/config/log4rs.yml
file. After callingconfigure_logger
fromlogging.rs
the logger should be available in thecalling thread and all children threads.
Second part of this PR is the mechanism that captures
stderr
output fromplugins. We setup a customized drain (
DecoratingPipe
) for pluginprocesses in
zellij-server/src/wasm_vm.rs
. TheDecoratingPipe
logs thestderr
output from plugins using the same logger as we will use everywhereelse but with custom format.
Implements: #561
Todo:
DecoratingPipe::flush
) make sure we detect byte boundaries correctly inDecoratingPipe::write
Note:
I didn't go with
slog
due to it not being fully compatible with standard rustlog::info
(warn, err etc.), instead that project prefers to use it's ownslog::info
(warn, err etc.). I tried to use adapter provided by slog project but it was difficult to share the logger between packages. Slog basically expects you to pass log instance across your codebase, which seems like a lot of effort in case of a project that wasn't initially created with slog usage in mind. Also, there is no official support for adding thread name to log, emitting colored log to file or filtering modules.Sample from log file: