tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.39k stars 707 forks source link

Missing space when using pretty formatter without target #1353

Open djc opened 3 years ago

djc commented 3 years ago

Bug Report

Version

tracing: 0.1.25 tracing-subscriber: 0.2.17

Platform

macOS Big Sur

Description

If I set up the tracing subscriber like this:

tracing_subscriber::fmt().with_target(false).pretty().init();

I get out put like this:

  Apr 13 02:20:01.562  WARNinvalid domain: Errors { start_combining_mark }, etld: Etld("io"), domain: "xn--q3caq5e0f", path: "data/2021-03-17/securitytrails/securitytrails-all.csv"
    at shared/src/lib.rs:352

The lack of a space between the level and the event message seems like an oversight (perhaps related to disabling the target).

anelson commented 3 years ago

I can confirm I'm seeing the same thing, but I am not using with_target(false):

  Apr 30 08:41:29.138  INFOconsole: message from print_info, some_field: 43
    at cheburashka/examples/cli.rs:19

  Apr 30 08:41:29.138  WARNconsole: message from print_warn, some_field: 44
    at cheburashka/examples/cli.rs:20

  Apr 30 08:41:29.138 ERRORconsole: message from print_error, some_field: 45
    at cheburashka/examples/cli.rs:21

(in the above output, console is the target).

Also using tracing-subscriber 0.2.17

Shadow53 commented 3 years ago

Can also confirm the same with the following minimal program:

// main.rs
fn main() {
    tracing_subscriber::FmtSubscriber::builder().pretty().init();
    tracing::info!("Some output");
}
tracing-subscriber = "0.2.18"
tracing = "0.1.26"

Edit: forgot output:

  Jun 19 22:45:48.183  INFOtesting: Some output
    at src/main.rs:3
Shadow53 commented 3 years ago

Looks like this is a duplicate of #1309

Shadow53 commented 3 years ago

BTW, until the fix gets backported, I managed to "fix" the issue by telling the pretty formatter to not output source location:

use tracing_subscriber::fmt::format::Pretty;
fn main() {
    let formatter = Pretty::default().with_source_location(false);
    tracing_subscriber::fmt().fmt_fields(formatter).init();
    tracing::info!("Some output");
}