Tracing log sources

I have a question regarding the tracing crate. Is it possible to omit the trace source from the logs? For example, I want to omit sources such as "/home/mohamed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.2/src/logger.rs:144" and "/home/mohamed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.5.2/src/trace/on_request.rs:80" from the following logs

 2024-09-27T14:23:40.235889Z DEBUG tower_http::trace::on_request: started processing request
    at /home/mohamed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.5.2/src/trace/on_request.rs:80
    in tempo::router::request with request_id: 877cb373-6202-4afe-9bb5-e28e398def05, method: POST, uri: /subscribe, version: HTTP/1.1

  2024-09-27T14:23:40.254435Z DEBUG sqlx::query: summary: "insert into subscriptions (id, …", db.statement: "\n\ninsert into\n  subscriptions (id, email, name, subscribed_at)\nvalues\n  ($1, $2, $3, $4)\nreturning\n  *\n", rows_affected: 0, rows_returned: 1, elapsed: 8.514988ms, elapsed_secs: 0.008514988
    at /home/mohamed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.2/src/logger.rs:144
    in tempo::router::subscriptions::Adding a new subscriber with email: myemail, name: wood
    in tempo::router::request with request_id: 877cb373-6202-4afe-9bb5-e28e398def05, method: POST, uri: /subscribe, version: HTTP/1.1

Thank you for your help.

Assuming you're using tracing_subscriber

Instead of calling:

tracing_subscriber::fmt().init();

You'd do something like:

tracing_subscriber::fmt()
    .with_file(false)
    .with_line_number(false)
    .init();
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.