-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add option to provide custom writer to the logger backend #518
Conversation
@@ -121,6 +158,7 @@ impl ServiceCore for Logger { | |||
} | |||
LoggerBackend::Stdout => tracing_appender::non_blocking(std::io::stdout()), | |||
LoggerBackend::Stderr => tracing_appender::non_blocking(std::io::stderr()), | |||
LoggerBackend::Writer(writer) => tracing_appender::non_blocking(writer), |
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.
Could you elaborate on the use case of this writer? For example, sending logs via network to fluentd?
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.
Main reason was because I wanted to collect logs in the chat app but at the same time control how those are printed to stdout.
I think it could also be useful in tests where instead of dumping logs into a file and then reading you could directly read them on the fly.
This is general enough that it can be used in multiple ways I think
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 get it. Thank you for your comment!
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.
👍
* Add option to provide custom writer to the logger backend * fmt
This might be helpful in tests or other cases where you want to collect and process logs produced by another application in real time