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

Bug: In some scenarios, log content is lost. #2901

Open
karellincoln opened this issue Mar 6, 2024 · 2 comments
Open

Bug: In some scenarios, log content is lost. #2901

karellincoln opened this issue Mar 6, 2024 · 2 comments

Comments

@karellincoln
Copy link

Bug Report

Version

tracing = "0.1.40"

│   │   └── tracing v0.1.40
│   │       ├── tracing-attributes v0.1.27 (proc-macro)
│   │       └── tracing-core v0.1.32
│   │   │   │   └── tracing v0.1.40 (*)
│   │   │   └── tracing v0.1.40 (*)
│   │   └── tracing v0.1.40 (*)
│   └── tracing v0.1.40 (*)
│   └── tracing v0.1.40 (*)
├── tracing v0.1.40 (*)
└── tracing-subscriber v0.3.18
    ├── tracing v0.1.40 (*)
    ├── tracing-core v0.1.32 (*)
    └── tracing-log v0.2.0
        └── tracing-core v0.1.32 (*)
│   │   └── tracing v0.1.40 (*)
│   │   ├── tracing v0.1.40 (*)

Platform

Mac Mini M1

Description

code:

    #[test]
    fn log_test() {
        tracing_subscriber::registry()
            .with(
                tracing_subscriber::EnvFilter::try_from_default_env()
                    .unwrap_or_else(|_| "info".into()),
            )
            .with(tracing_subscriber::fmt::layer())
            .init();

        info!("{}", "{}".to_string());
        info!("finished!!!");

        info!("{}", "{\"a\":\"a\"}".to_string());
        info!("finished!!!");

        info!("---- {}", "{\"a\":\"a\"}".to_string());
        info!("finished!!!");
    }

image

@karellincoln karellincoln changed the title In some scenarios, log content is lost. Bug: In some scenarios, log content is lost. Mar 6, 2024
@kaffarell
Copy link
Contributor

I am on the exact same versions and executed exactly the same code as you and get the correct output:

2024-03-06T14:48:58.857352Z  INFO rust_test: {}
2024-03-06T14:48:58.857418Z  INFO rust_test: finished!!!
2024-03-06T14:48:58.857426Z  INFO rust_test: {"a":"a"}
2024-03-06T14:48:58.857432Z  INFO rust_test: finished!!!
2024-03-06T14:48:58.857438Z  INFO rust_test: ---- {"a":"a"}
2024-03-06T14:48:58.857443Z  INFO rust_test: finished!!!

But as you use the EnvFilter you are setting a filter according to your RUST_LOG environment variable. Please post that one as well :)

@mladedav
Copy link
Contributor

What rust/cargo version are you using? If it's possible, can you try your repro on the latest stable?

The arguments you're passing into the macro invocation should all be passed to format_args! so it's possible there was a bug or there is one on your platform. Does the same code work for you when you use println! instead of tracing::info!?

I wasn't able to reproduce it either.

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

3 participants