Skip to content
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

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

zeegomo
Copy link
Contributor

@zeegomo zeegomo commented Nov 6, 2023

This might be helpful in tests or other cases where you want to collect and process logs produced by another application in real time

@zeegomo zeegomo added enhancement New feature or request test testnet labels Nov 6, 2023
@zeegomo zeegomo added this to the Nomos testnet (playground) milestone Nov 6, 2023
@zeegomo zeegomo self-assigned this Nov 6, 2023
@@ -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),
Copy link
Contributor

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?

Copy link
Contributor Author

@zeegomo zeegomo Nov 6, 2023

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

Copy link
Contributor

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!

Copy link
Contributor

@youngjoon-lee youngjoon-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@zeegomo zeegomo merged commit 3028cdb into master Nov 7, 2023
7 checks passed
al8n pushed a commit that referenced this pull request Nov 8, 2023
* Add option to provide custom writer to the logger backend

* fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test testnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants