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

Support writing structured data directly, without JSON encoding #50

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

reachfh
Copy link
Contributor

@reachfh reachfh commented Jan 4, 2024

Adds a new option to output the structured log message as a map instead of encoding it as JSON.

This works better when using a logger formatter that encodes all log messages as JSON, avoiding double encoding.
See my library logger_formatter_json.

With logger_formatter_json, the output is something like this:

{"msg":{"status":"200","path":"/","method":"GET","timing":"1ms","client_ip":"10.10.102.99","duration_ms":1.286,"x_forwarded_port":"443","x_forwarded_proto":"https","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","x_forwarded_for":"104.187.140.60"},"level":"info","file":"lib/uinta/plug.ex","line":"157","pid":"<0.3289.0>","request_id":"F6c-8tPDkCM2Ag4AAA4y","otel_trace_id":"659715447dcfbd23bc524d9bfc7a3992","otel_span_id":"e2e08b0504fbcc76"}

@epinault
Copy link
Contributor

epinault commented Jan 8, 2024

thank you for your contribution! I ll merge this after we fix the issue below and try to get a release later today. I will need to create a new minor and document the breaking change in the changelog

@epinault epinault merged commit 74e8eb3 into podium:master Jan 9, 2024
12 checks passed
@epinault
Copy link
Contributor

epinault commented Jan 9, 2024

Fixed in #53. And just published a new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants