From 040088ccd03a246a2cd73887974e7ec54badeb61 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Mon, 17 Oct 2022 08:52:10 -0700 Subject: [PATCH] debug based on env var --- rust/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 73bf577..a34ba0f 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,3 +1,5 @@ +use std::env; + use chunk::{Chunk, OpCode}; use vm::VM; @@ -10,8 +12,12 @@ mod value; mod vm; fn main() -> Result<()> { + let level = match env::var("DEBUG") { + Ok(_) => Level::DEBUG, + Err(_) => Level::ERROR, + }; let subscriber = FmtSubscriber::builder() - .with_max_level(Level::DEBUG) + .with_max_level(level) .finish(); tracing::subscriber::set_global_default(subscriber) .wrap_err("setting default subscriber failed")?;