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

journald: Do not log additional string data in Debug representation #1710

Closed
swsnr opened this issue Nov 4, 2021 · 6 comments
Closed

journald: Do not log additional string data in Debug representation #1710

swsnr opened this issue Nov 4, 2021 · 6 comments

Comments

@swsnr
Copy link
Contributor

swsnr commented Nov 4, 2021

Bug Report

Follow up from #1709 (comment)

Description

tracing-journald currently logs additional string fields in their Debug representation, i.e. this code

info!(foo="foo", "test")

writes FOO="foo" to the journal, i.e. with extra quotes from format!("{:?}").

I expected FOO=foo, i.e. a regular string.

@swsnr
Copy link
Contributor Author

swsnr commented Nov 4, 2021

@Ralith You've said over in the merge request that this is intended because it helps distinguish between 1 as a number, and 1 as a string, which one couldn't if strings were logged directly.

I understand the motivation, but my concern is that this effectively requires downstream consumers of the journal to "unparse" Rust's Debug representation in order to get the original string back out.

It also seems rather unusual to add extra formatting to field values, as far as I can see: The slog implementation uses Display, not Debug, and I superficially (my C's a bit rusty 😉 ) checked Glib's structured logging code, and it seems to treat all fields as strings upfront, unless they contain internal NULs.

@Ralith
Copy link
Collaborator

Ralith commented Nov 4, 2021

On review I think I agree; the common case (especially in idiomatic journald clients) of working with strings trumps the rather weird case of meaningfully dynamically-typed fields. I'd be happy to approve a fix.

@swsnr
Copy link
Contributor Author

swsnr commented Nov 5, 2021

I'll make a MR after the tests are merged.

We can also have a flag, similar to the field prefix, to toggle between the literal and the debug representation of strings, if you like 🙂

@Ralith
Copy link
Collaborator

Ralith commented Nov 5, 2021

Eh, I'd rather avoid the complexity.

@swsnr
Copy link
Contributor Author

swsnr commented Nov 5, 2021

Absolutely fine with me 🙂 I'll make a merge request after #1709

@Ralith Thanks for your great support and your help 🙏

@Ralith
Copy link
Collaborator

Ralith commented Nov 5, 2021

Thanks for the contributions!

@hawkw hawkw closed this as completed in 01f93a7 Nov 20, 2021
hawkw pushed a commit that referenced this issue Dec 2, 2021
See #1710: Do not write strings in Debug representation.

## Motivation

As discussed in #1710 writing strings literally makes tracing-journald
behave like other journal clients, and allows 3rd party journal readers
to extract the original value from the journal without having to
"un"-parse the Debug representation of Rust strings.

Fixes #1710.
hawkw pushed a commit that referenced this issue Dec 3, 2021
See #1710: Do not write strings in Debug representation.

## Motivation

As discussed in #1710 writing strings literally makes tracing-journald
behave like other journal clients, and allows 3rd party journal readers
to extract the original value from the journal without having to
"un"-parse the Debug representation of Rust strings.

Fixes #1710.
hawkw pushed a commit that referenced this issue Dec 19, 2021
See #1710: Do not write strings in Debug representation.

## Motivation

As discussed in #1710 writing strings literally makes tracing-journald
behave like other journal clients, and allows 3rd party journal readers
to extract the original value from the journal without having to
"un"-parse the Debug representation of Rust strings.

Fixes #1710.
hawkw pushed a commit that referenced this issue Dec 19, 2021
See #1710: Do not write strings in Debug representation.

## Motivation

As discussed in #1710 writing strings literally makes tracing-journald
behave like other journal clients, and allows 3rd party journal readers
to extract the original value from the journal without having to
"un"-parse the Debug representation of Rust strings.

Fixes #1710.
hawkw pushed a commit that referenced this issue Dec 20, 2021
See #1710: Do not write strings in Debug representation.

## Motivation

As discussed in #1710 writing strings literally makes tracing-journald
behave like other journal clients, and allows 3rd party journal readers
to extract the original value from the journal without having to
"un"-parse the Debug representation of Rust strings.

Fixes #1710.
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

No branches or pull requests

2 participants