Closed IvanovOleg closed 5 months ago
To make it easier to copy/paste, I made
#!/usr/bin/env nargo
---
[dependencies]
log = "0.4"
env_logger = "0.11"
---
use log::info;
fn main() {
env_logger::init();
info!("program started");
println!("Hello world!");
}
$ ./run.rs
Hello World!
$ RUST_LOG=trace ./run.rs
[2024-02-16T17:04:41Z INFO env_logger_311] program started
Hello world!
By default env_logger
reports nothing back. You can use filter_level
to set the level you want shown. clap-verbosity-flag
helps provide a CLI for this.
As this is working as expected, I'm going to go ahead and close this. If there is a reason we should re-evaluate, let us know!
PS C:\Users\oliva\Documents\playground> Set-Variable -Name "RUST_LOG" -Value "trace"
PS C:\Users\oliva\Documents\playground> echo $RUST_LOG
trace
PS C:\Users\oliva\Documents\playground> cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `target\debug\playground.exe`
Hello world!
PS C:\Users\oliva\Documents\playground>
I have no powershell experience so I can't answer to what is going wrong between powershell and env_logger.
PS C:\Users\oliva\Documents\playground> $Env:RUST_LOG = 'trace'
PS C:\Users\oliva\Documents\playground> $Env:RUST_LOG
trace
PS C:\Users\oliva\Documents\playground> cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target\debug\playground.exe`
[2024-02-16T17:28:54Z INFO playground] program started
Hello world!
Hello, I have a simple app that should log one string, but it doesn't: Cargo.toml:
main.rs:
Result:
Tried using https://play.rust-lang.org/ as well, no output!