如果我们有以下代码
fn main() {
error!("This is an error log")
warn!("This is a warn log")
info!("this is an info log")
debug!("This is a debug log")
}
如何在Windows上启用调试级输出?
如果我们有以下代码
fn main() {
error!("This is an error log")
warn!("This is a warn log")
info!("this is an info log")
debug!("This is a debug log")
}
如何在Windows上启用调试级输出?
执行程序时,需要适当设置RUST_LOG
环境变量;就这一点而言,它是一个逗号分隔的键=值列表; keys 是 crate 或模块名称,例如extra
或std::option
;这些值是映射到日志(log)级别的数字:
(每个级别包括更重要的级别.)
在命令提示符下,编译并运行myprog
并显示警告和错误如下:
rustc myprog.rs
set RUST_LOG=myprog=4
myprog.exe