1

Trying to understand an open source project and I have seen the following code in many places

debug!("called with params: {:?}", body); // or some parameter instead of bo

when I run cargo run I do not see any of these outputs in the console. only the INFO logs are displayed

[2022-12-19T13:53:23Z INFO actix_server::builder] Starting 8 workers [2022-12-19T13:53:23Z INFO actix_server::server] Actix runtime found; starting in Actix runtime

[2022-12-19T14:00:58Z INFO actix_web::middleware::logger] ::1 "GET /stats HTTP/1.1" 200 49 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" 0.009129 [2022-12-

I tried running RUST_LOG=debug cargo run. but still unable to see the debug output. as I can see the logging is configured via rust-log crate. but with my limited experience with rust I couldn't figure out more. I assume these debug logs are in some file but not sure exactly where they are.

Shobi
  • 10,374
  • 6
  • 46
  • 82
  • [There's an option in `struct Opt` called `log_level`](https://github.com/meilisearch/meilisearch/blob/867279f2a45e805bcee0e0fd5865f25a7a03c6fd/meilisearch/src/option.rs#L231), so I assume that the log level can be set by a command line option. The field `log_level` is [used in `main.rs` here](https://github.com/meilisearch/meilisearch/blob/867279f2a45e805bcee0e0fd5865f25a7a03c6fd/meilisearch/src/main.rs#L19) as the filter. – kotatsuyaki Dec 19 '22 at 14:19
  • 1
    Great, I found it `cargo run -- --log-level=debug` started outputting debug logs. If you can write an answer I can accept it – Shobi Dec 19 '22 at 14:34

1 Answers1

1

meilisearch provides a command line option --log-level=... for users to specify the log level, which can contain any filter string that's accepted by the env_logger crate. To enable all the log::debug! outputs, supply --log-level=debug when running the binary.

# If building from source
cargo run -- --log-level=debug

# If installed
meilisearch --log-level=debug

See the documentation of env_logger for the syntax of filter strings.

kotatsuyaki
  • 1,441
  • 3
  • 10
  • 17