Skip to content

subscriber: fix excessive padding on log messages#3070

Closed
kaffarell wants to merge 1 commit intotokio-rs:masterfrom
kaffarell:subscriber_log_spaces
Closed

subscriber: fix excessive padding on log messages#3070
kaffarell wants to merge 1 commit intotokio-rs:masterfrom
kaffarell:subscriber_log_spaces

Conversation

@kaffarell
Copy link
Copy Markdown
Contributor

@kaffarell kaffarell commented Sep 2, 2024

Don't add padding to log.* attributes (from log events) which are not outputted.

Problem

For example this config which automatically transforms log-events to tracing ones:

tracing_subscriber::fmt()
    .with_max_level(tracing::Level::TRACE)
    .init();

With the following log message:

log::debug!("this is a log line");

Prints something like:
"this is a log line \n"

Solution

Do something like in the PrettyVisitor: add a write helper which automatically pads every write.

Note: this would also need to be backported to v0.1.x!

@kaffarell kaffarell requested review from a team and hawkw as code owners September 2, 2024 09:08
@kaffarell
Copy link
Copy Markdown
Contributor Author

CI errors are unrelated, will be fixed with #3069. ping @hawkw @davidbarsky.

Don't add padding to `log.*` attributes (from `log` events) which are
not outputted.

## Problem
For example this config which automatically transforms `log`-events to
`tracing` ones:

```rust
tracing_subscriber::fmt()
    .with_max_level(tracing::Level::TRACE)
    .init();
```

With the following log message:

```rust
log::debug!("this is a log line");
```

Prints something like:
"this is a log line   \n"

## Solution
Do something like in the PrettyVisitor: add a write helper which
automatically pads every write.
@kaffarell kaffarell force-pushed the subscriber_log_spaces branch from df8c08c to 808faf6 Compare September 3, 2024 08:07
@kaffarell kaffarell requested a review from yaahc as a code owner September 3, 2024 08:07
@kaffarell kaffarell changed the base branch from v0.1.x to master September 3, 2024 08:07
@kaffarell
Copy link
Copy Markdown
Contributor Author

kaffarell commented Dec 2, 2024

Fixed by #2980 :)

@kaffarell kaffarell closed this Dec 2, 2024
aspirexio pushed a commit to virbula/proxmox-backup that referenced this pull request Dec 23, 2025
When using the `log` to `tracing` translation layer, the messages get
padded with whitespaces. This bug will get fixed upstream [0], but in
the meantime we switch to the `tracing` macros.

[0]: tokio-rs/tracing#3070

Tested-by: Christian Ebner <c.ebner@proxmox.com>
Reviewed-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
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.

1 participant