Skip to content

feat: support logfmt layout#114

Merged
tisonkun merged 8 commits intofast:mainfrom
kemingy:logfmt
Apr 1, 2025
Merged

feat: support logfmt layout#114
tisonkun merged 8 commits intofast:mainfrom
kemingy:logfmt

Conversation

@kemingy
Copy link
Copy Markdown
Contributor

@kemingy kemingy commented Mar 24, 2025

This closes #98.

kemingy added 3 commits March 24, 2025 23:40
Signed-off-by: Keming <kemingy94@gmail.com>
Signed-off-by: Keming <kemingy94@gmail.com>
@tisonkun
Copy link
Copy Markdown
Contributor

Thank you! I'll review this patch by the end of next week. Feel free to ping me if I meet the estimate.

kemingy and others added 2 commits March 28, 2025 14:40
Signed-off-by: tison <wander4096@gmail.com>
@kemingy
Copy link
Copy Markdown
Contributor Author

kemingy commented Mar 30, 2025

kemingy added 2 commits March 31, 2025 17:20
Signed-off-by: Keming <kemingy94@gmail.com>
@kemingy kemingy requested a review from tisonkun March 31, 2025 13:07
@tisonkun
Copy link
Copy Markdown
Contributor

tisonkun commented Apr 1, 2025

Yeah. I think that if the key/value has \r\n\\\t\b there would be some issue. But let's simply implement what logfmt does so far and update if any user complain.

Signed-off-by: tison <wander4096@gmail.com>
Comment on lines +76 to +79
if key.contains([' ', '=', '"']) {
// omit keys contain special chars
return;
}
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

@tisonkun tisonkun left a 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.

@tisonkun tisonkun merged commit ab10f76 into fast:main Apr 1, 2025
9 checks passed
@tisonkun
Copy link
Copy Markdown
Contributor

tisonkun commented Apr 1, 2025

Thanks for your contribution!

@kemingy kemingy deleted the logfmt branch April 1, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement logfmt layout

2 participants