debug based on env var

main
Alpha Chen 2 years ago
parent fc2320cb81
commit 040088ccd0
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -1,3 +1,5 @@
use std::env;
use chunk::{Chunk, OpCode}; use chunk::{Chunk, OpCode};
use vm::VM; use vm::VM;
@ -10,8 +12,12 @@ mod value;
mod vm; mod vm;
fn main() -> Result<()> { fn main() -> Result<()> {
let level = match env::var("DEBUG") {
Ok(_) => Level::DEBUG,
Err(_) => Level::ERROR,
};
let subscriber = FmtSubscriber::builder() let subscriber = FmtSubscriber::builder()
.with_max_level(Level::DEBUG) .with_max_level(level)
.finish(); .finish();
tracing::subscriber::set_global_default(subscriber) tracing::subscriber::set_global_default(subscriber)
.wrap_err("setting default subscriber failed")?; .wrap_err("setting default subscriber failed")?;

Loading…
Cancel
Save