Skip to content

Commit

Permalink
fix: print debug statements only when --debug is set
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Feb 6, 2025
1 parent 3fa3903 commit 58e6707
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ serde_yaml = "0.9.34"
sha2 = "0.10"
time = "0.3"
toml = "0.8"
tracing = "0.1"
tracing = { version = "0.1", features = ["release_max_level_info"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
walkdir = "2.4"

Expand Down
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ fn main() -> Result<()> {
// 1) Parse CLI + config files:
let mut full_config = YekConfig::init_config();

let env_filter = if cfg!(debug_assertions) && full_config.debug {
"yek=debug,ignore=off"
} else {
"yek=info,ignore=off"
};

// 2) Initialize tracing:
fmt::Subscriber::builder()
.with_max_level(if full_config.debug {
.with_max_level(if cfg!(debug_assertions) && full_config.debug {
Level::DEBUG
} else {
Level::INFO
Expand All @@ -23,7 +29,7 @@ fn main() -> Result<()> {
.with_file(false)
.with_line_number(false)
.with_level(true)
.with_env_filter("yek=debug,ignore=off")
.with_env_filter(env_filter)
.compact()
.init();

Expand Down

0 comments on commit 58e6707

Please sign in to comment.