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

Replace newlines in log strings #333

Merged
merged 2 commits into from
Dec 14, 2020
Merged

Conversation

bensymonds
Copy link
Contributor

Pliny logging follows the "logfmt" pattern. logfmt is unclear on what should happen with newline characters, but given it's line-based it doesn't seem to make sense to include them in the body of the log line. I couldn't decide between removing, replacing with a space character, or escaping. In the end I went with escaping since it makes it clear to a viewer that a newline was there.

This includes a small refactor - see the commits for details.

It seemed better to extract the `key=value` construction so it's done in a single place. This also allows futher processing of the string to be added later.
Pliny logging follows the "logfmt" pattern[1]. logfmt is unclear on what should happen with newline characters, but given it's line-based it doesn't seem to make sense to include them in the body of the log line. I couldn't decide between removing, replacing with a space character, or escaping. In the end I went with escaping since it makes it clear to a viewer that a newline _was_ there.

[1] https://brandur.org/logfmt
@bensymonds
Copy link
Contributor Author

@stevenharman If you're thinking about merging and releasing #338, maybe we could get this one in too?

@beanieboi beanieboi merged commit 286fb53 into master Dec 14, 2020
@beanieboi beanieboi deleted the replace-newlines-in-log-strings branch December 14, 2020 10:28
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.

2 participants