diff --git a/kernel/include/log/Log.h b/kernel/include/log/Log.h index ad8292e0..22c39595 100644 --- a/kernel/include/log/Log.h +++ b/kernel/include/log/Log.h @@ -14,6 +14,7 @@ namespace KernelLog { void log(const char* function, LogLevel level, const char* message, ...) PRINTF_LIKE(3, 4); void logln(const char* function, LogLevel level, const char* message, ...) PRINTF_LIKE(3, 4); + void toggle_log_level(LogLevel level); } #ifndef MODULE diff --git a/kernel/src/log/Log.cpp b/kernel/src/log/Log.cpp index 53eb16d6..eff893c4 100644 --- a/kernel/src/log/Log.cpp +++ b/kernel/src/log/Log.cpp @@ -4,8 +4,11 @@ #include "std/stdio.h" #include +static int level_mask = 15; + void KernelLog::log(const char* function, LogLevel level, const char* message, ...) { + if (!(level_mask & (1 << (int)level))) return; va_list ap; va_start(ap, message); Serial::reset_color(); @@ -25,6 +28,7 @@ void KernelLog::log(const char* function, LogLevel level, const char* message, . void KernelLog::logln(const char* function, LogLevel level, const char* message, ...) { + if (!(level_mask & (1 << (int)level))) return; va_list ap; va_start(ap, message); Serial::reset_color(); @@ -41,4 +45,9 @@ void KernelLog::logln(const char* function, LogLevel level, const char* message, Serial::reset_color(); Serial::print("\n"); va_end(ap); +} + +void KernelLog::toggle_log_level(LogLevel level) +{ + level_mask ^= (1 << (int)level); } \ No newline at end of file