How to set logging level during cargo check?

I need to change the logging level while running unit tests for the library. I use the cargo test command to run the tests.

Can I specify the level of logging on the command line? From the drawer tray documentation, it seems I need to define the environment variable separately. This may be inconvenient, since I would like to change the debug logging level only if the test case fails.

+5
source share
1 answer

Cargo does not support this yet, but you can file an issue for it.

RUST_LOG=debug cargo test should work, you can set environment variables for single commands, and not set them for the current environment.

Additional information on the variable RUST_LOG env is here .

+4
source

Source: https://habr.com/ru/post/1206431/


All Articles