I need to change the logging level while running the unit tests for a library. I am using the cargo test
command to run the tests.
Is there any way to specify the logging level on the command line? From the documentation of the log crate, it seems like I need to define an environment variable separately. That may not be convenient as I would like to change the logging level to debug only when a test case fails.
Server Configuration File You can change the log level through a Windows Registry file or a Linux configuration file. Add the logLevel string, and set the desired value (e.g., DEBUG). Click OK to save.
The default behavior of the binary produced by cargo test is to run all the tests in parallel and capture output generated during test runs, preventing the output from being displayed and making it easier to read the output related to the test results.
cargo test runs additional checks as well. It will compile any examples you've included to ensure they are still compiles. It also run documentation tests to ensure your code samples from documentation comments compiles.
Cargo doesn't support this yet, but you are welcome to file an issue for it.
RUST_LOG=debug cargo test
should work, you can set environment variables for single commands instead of setting them for the current environment.
More info on the RUST_LOG
env variable here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With