diff --git a/Makefile b/Makefile index 45611c8..6cd1215 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ # make run Run in debug # make run int=1 Run with interrupt info by QEMU # make run mode=release Run in release +# make run LOG=error Run with log level: error +# LOG = off | error | warn | info | debug | trace # make doc Generate docs # make asm Open the deassemble file of the last build # make clean Clean @@ -24,6 +26,7 @@ user_object_files := $(patsubst user/%.img, build/user/%.o, $(user_image_files)) qemu_opts := -cdrom $(iso) -smp 4 -serial mon:stdio features := use_apic +LOG ?= debug link_user = 1 ifdef link_user diff --git a/src/io/mod.rs b/src/io/mod.rs index ae16a13..a2f734a 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -6,7 +6,14 @@ mod vga_writer; pub fn init() { static LOGGER: SimpleLogger = SimpleLogger; log::set_logger(&LOGGER).unwrap(); - log::set_max_level(LevelFilter::Debug); + log::set_max_level(match option_env!("LOG") { + Some("off") => LevelFilter::Off, + Some("error") => LevelFilter::Error, + Some("warn") => LevelFilter::Warn, + Some("info") => LevelFilter::Info, + Some("trace") => LevelFilter::Trace, + Some("debug") | _ => LevelFilter::Debug, + }); } macro_rules! print {