How to set logging level while running cargo test? [duplicate]

一曲冷凌霜 提交于 2019-12-12 09:38:18

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/26804441/how-to-set-logging-level-while-running-cargo-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!