Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Guidance needed: Custom JSON formatter #2391

Closed
lcmgh opened this issue Nov 17, 2022 · 1 comment
Closed

Guidance needed: Custom JSON formatter #2391

lcmgh opened this issue Nov 17, 2022 · 1 comment

Comments

@lcmgh
Copy link

lcmgh commented Nov 17, 2022

Hi!

What I need is a JSON formatter that prints logs in a custom JSON schema / struct format.

There are some mandatory fields that should be set initially (e.g. environment such as test, prod) and printed out with every log entry without the need of specifying it in every log call (such as info!("..")) call. Some other fields are optional. Could I include optional fields with info!(key=value) ?

I need some guidance how I should implement that. Is it a good idea to copy tracing's JSON Formatter (quite a bunch of code) and align it to my custom data structure or should I rather use a Layer (on top of the JSON Formatter?)?

Thanks for your input

@lcmgh
Copy link
Author

lcmgh commented Nov 17, 2022

Just found a related issue #2391

@tokio-rs tokio-rs locked and limited conversation to collaborators Nov 17, 2022
@hawkw hawkw converted this issue into discussion #2393 Nov 17, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant