-
Notifications
You must be signed in to change notification settings - Fork 15
feat: support logfmt layout #114
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
Conversation
Signed-off-by: Keming <[email protected]>
Signed-off-by: Keming <[email protected]>
Thank you! I'll review this patch by the end of next week. Feel free to ping me if I meet the estimate. |
Signed-off-by: tison <[email protected]>
AFAIK, there is no official spec for logfmt. The article is the source. Grafana Loki is using https://github.com/go-logfmt/logfmt, which could be seen as a successor of https://github.com/kr/logfmt.
Also found some interesting discussions in the Python implementation: josheppinette/python-logfmter#15 |
Signed-off-by: Keming <[email protected]>
Yeah. I think that if the key/value has |
Signed-off-by: tison <[email protected]>
if key.contains([' ', '=', '"']) { | ||
// omit keys contain special chars | ||
return; | ||
} |
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.
Maybe return an error as go logfmt does. But it would require diagnostic visitor's visit failable and I'll leave it for a follow-up.
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.
Will the key contain special chars? AFAIK, it's set from the log
with feature kv
like:
info!(key = "something else"; "here is the msg");
It's guaranteed by the compiler.
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.
This is possible and how go logfmt implements it.
It's guaranteed by the compiler.
The compiler guarantees it's an expr; nothing more. https://github.com/rust-lang/log/blob/71d533f9bb35fcbb75979ad4fe9743b80c6a8ba4/src/macros.rs#L445-L454
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.
TIL. Thanks for the information.
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.
LGTM. Pending for merging.
Thanks for your contribution! |
This closes #98.