-
Notifications
You must be signed in to change notification settings - Fork 721
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
subscriber: remove space when timestamps are disabled #1355
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Currently, the default `Compact` and `Full` formatters in `tracing-subscriber` will prefix log lines with a single space when timestamps are disabled. The space is emitted in order to pad the timestamp from the rest of the log line, but it shouldn't be emitted when timestamps are turned off. This should be fixed. This branch fixes the issue by skipping `time::write` entirely when timestamps are disabled. This is done by tracking an additional boolean flag for disabling timestamps. Incidentally, this now means that span lifecycle timing can be enabled even if event timestamps are disabled, like this: ```rust use tracing_subscriber::fmt; let subscriber = fmt::subscriber() .without_time() .with_timer(SystemTime::now) .with_span_events(fmt::FmtSpan::FULL); ``` or similar. Closes #1354
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw
changed the title
Eliza/fix bonus space
subscriber: remove space when timestamps are disabled
Apr 13, 2021
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
davidbarsky
approved these changes
Apr 13, 2021
hawkw
added a commit
that referenced
this pull request
Apr 16, 2021
## Motivation Currently, the default `Compact` and `Full` formatters in `tracing-subscriber` will prefix log lines with a single space when timestamps are disabled. The space is emitted in order to pad the timestamp from the rest of the log line, but it shouldn't be emitted when timestamps are turned off. This should be fixed. ## Solution This branch fixes the issue by skipping `time::write` entirely when timestamps are disabled. This is done by tracking an additional boolean flag for disabling timestamps. Incidentally, this now means that span lifecycle timing can be enabled even if event timestamps are disabled, like this: ```rust use tracing_subscriber::fmt; let subscriber = fmt::subscriber() .without_time() .with_timer(SystemTime::now) .with_span_events(fmt::FmtSpan::FULL); ``` or similar. I also added a new test reproducing the issue, and did a little refactoring to try and clean up the timestamp formatting code a bit. Closes #1354
Merged
hawkw
added a commit
that referenced
this pull request
Apr 16, 2021
## Motivation Currently, the default `Compact` and `Full` formatters in `tracing-subscriber` will prefix log lines with a single space when timestamps are disabled. The space is emitted in order to pad the timestamp from the rest of the log line, but it shouldn't be emitted when timestamps are turned off. This should be fixed. ## Solution This branch fixes the issue by skipping `time::write` entirely when timestamps are disabled. This is done by tracking an additional boolean flag for disabling timestamps. Incidentally, this now means that span lifecycle timing can be enabled even if event timestamps are disabled, like this: ```rust use tracing_subscriber::fmt; let subscriber = fmt::subscriber() .without_time() .with_timer(SystemTime::now) .with_span_events(fmt::FmtSpan::FULL); ``` or similar. I also added a new test reproducing the issue, and did a little refactoring to try and clean up the timestamp formatting code a bit. Closes #1354
hawkw
added a commit
that referenced
this pull request
Apr 17, 2021
## Motivation Currently, the default `Compact` and `Full` formatters in `tracing-subscriber` will prefix log lines with a single space when timestamps are disabled. The space is emitted in order to pad the timestamp from the rest of the log line, but it shouldn't be emitted when timestamps are turned off. This should be fixed. ## Solution This branch fixes the issue by skipping `time::write` entirely when timestamps are disabled. This is done by tracking an additional boolean flag for disabling timestamps. Incidentally, this now means that span lifecycle timing can be enabled even if event timestamps are disabled, like this: ```rust use tracing_subscriber::fmt; let subscriber = fmt::subscriber() .without_time() .with_timer(SystemTime::now) .with_span_events(fmt::FmtSpan::FULL); ``` or similar. I also added a new test reproducing the issue, and did a little refactoring to try and clean up the timestamp formatting code a bit. Closes #1354
hawkw
added a commit
that referenced
this pull request
Apr 30, 2021
# 0.2.18 (April 30, 2021) ### Deprecated - Deprecated the `CurrentSpan` type, which is inefficient and largely superseded by the `registry` API ([#1321]) ### Fixed - **json**: Invalid JSON emitted for events in spans with no fields ([#1333]) - **json**: Missing span data for synthesized new span, exit, and close events ([#1334]) - **fmt**: Extra space before log lines when timestamps are disabled ([#1355]) ### Added - **env-filter**: Support for filters on spans whose names contain any characters other than `{` and `]` ([#1368]) Thanks to @Folyd, and new contributors @akinnane and @aym-v for contributing to this release! [#1321]: #1321 [#1333]: #1333 [#1334]: #1334 [#1355]: #1355 [#1368]: #1368
hawkw
added a commit
that referenced
this pull request
May 1, 2021
# 0.2.18 (April 30, 2021) ### Deprecated - Deprecated the `CurrentSpan` type, which is inefficient and largely superseded by the `registry` API ([#1321]) ### Fixed - **json**: Invalid JSON emitted for events in spans with no fields ([#1333]) - **json**: Missing span data for synthesized new span, exit, and close events ([#1334]) - **fmt**: Extra space before log lines when timestamps are disabled ([#1355]) ### Added - **env-filter**: Support for filters on spans whose names contain any characters other than `{` and `]` ([#1368]) Thanks to @Folyd, and new contributors @akinnane and @aym-v for contributing to this release! [#1321]: #1321 [#1333]: #1333 [#1334]: #1334 [#1355]: #1355 [#1368]: #1368
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
## Motivation Currently, the default `Compact` and `Full` formatters in `tracing-subscriber` will prefix log lines with a single space when timestamps are disabled. The space is emitted in order to pad the timestamp from the rest of the log line, but it shouldn't be emitted when timestamps are turned off. This should be fixed. ## Solution This branch fixes the issue by skipping `time::write` entirely when timestamps are disabled. This is done by tracking an additional boolean flag for disabling timestamps. Incidentally, this now means that span lifecycle timing can be enabled even if event timestamps are disabled, like this: ```rust use tracing_subscriber::fmt; let subscriber = fmt::subscriber() .without_time() .with_timer(SystemTime::now) .with_span_events(fmt::FmtSpan::FULL); ``` or similar. I also added a new test reproducing the issue, and did a little refactoring to try and clean up the timestamp formatting code a bit. Closes tokio-rs#1354
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
# 0.2.18 (April 30, 2021) ### Deprecated - Deprecated the `CurrentSpan` type, which is inefficient and largely superseded by the `registry` API ([tokio-rs#1321]) ### Fixed - **json**: Invalid JSON emitted for events in spans with no fields ([tokio-rs#1333]) - **json**: Missing span data for synthesized new span, exit, and close events ([tokio-rs#1334]) - **fmt**: Extra space before log lines when timestamps are disabled ([tokio-rs#1355]) ### Added - **env-filter**: Support for filters on spans whose names contain any characters other than `{` and `]` ([tokio-rs#1368]) Thanks to @Folyd, and new contributors @akinnane and @aym-v for contributing to this release! [tokio-rs#1321]: tokio-rs#1321 [tokio-rs#1333]: tokio-rs#1333 [tokio-rs#1334]: tokio-rs#1334 [tokio-rs#1355]: tokio-rs#1355 [tokio-rs#1368]: tokio-rs#1368
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, the default
Compact
andFull
formatters intracing-subscriber
will prefix log lines with a single space whentimestamps are disabled. The space is emitted in order to pad the
timestamp from the rest of the log line, but it shouldn't be emitted
when timestamps are turned off. This should be fixed.
Solution
This branch fixes the issue by skipping
time::write
entirely whentimestamps are disabled. This is done by tracking an additional boolean
flag for disabling timestamps.
Incidentally, this now means that span lifecycle timing can be enabled
even if event timestamps are disabled, like this:
or similar.
I also added a new test reproducing the issue, and did a little
refactoring to try and clean up the timestamp formatting code a bit.
Closes #1354