Skip to content

Commit

Permalink
Merge pull request #221 from Screenly/feature/debug_env_var
Browse files Browse the repository at this point in the history
Adds: ability to set debug logger level for release builds
  • Loading branch information
korvyashka authored Sep 11, 2024
2 parents 994e5f1 + 3809b2d commit 2a9fe64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ glob = "0.3.1"
hex = "0.4.3"
http-auth-basic = "0.3.3"
indicatif = "0.17.2"
log = { version = "0.4.17", features = ["release_max_level_info", "max_level_debug"] }
log = { version = "0.4.17", features = ["release_max_level_debug", "max_level_debug"] }
openssl = { version = '0.10', features = ["vendored"] }
prettytable-rs = "0.10.0"
protobuf = "3.3.0"
Expand Down
17 changes: 15 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ extern crate prettytable;

use crate::authentication::{Authentication, AuthenticationError};
use clap::Parser;
use simple_logger::SimpleLogger;
use simple_logger::{init_with_env, SimpleLogger};

use std::env;

fn main() {
SimpleLogger::new().init().unwrap();
if env::var("RUST_LOG").is_ok() {
init_with_env().unwrap();
} else {
let log_level = {
if cfg!(debug_assertions) {
log::LevelFilter::Debug
} else {
log::LevelFilter::Info
}
};
SimpleLogger::new().with_level(log_level).init().unwrap();
}

let _sentry_dsn = "https://891eb4b6f8ff4f959fd76a587d9ab302@o4505481987489792.ingest.sentry.io/4505482139140096";

Expand Down

0 comments on commit 2a9fe64

Please sign in to comment.