Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log: Add option to set LevelFilter at compile time #53

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ impl log::Log for KernelLogger {

pub fn init() {
set_logger(&KernelLogger).expect("Can't initialize logger");
set_max_level(LevelFilter::Info);
// Determines LevelFilter at compile time
let log_level: Option<&'static str> = option_env!("HERMIT_LOG_LEVEL_FILTER");
let max_level: LevelFilter = match log_level {
Some("Error") => LevelFilter::Error,
Some("Debug") => LevelFilter::Debug,
Some("Off") => LevelFilter::Off,
Some("Trace") => LevelFilter::Trace,
Some("Warn") => LevelFilter::Warn,
Some("Info") => LevelFilter::Info,
_ => LevelFilter::Info,
};
set_max_level(max_level);
}

macro_rules! infoheader {
Expand Down