diff --git a/kernel/src/Log.cpp b/kernel/src/Log.cpp index 63519d43..67704922 100644 --- a/kernel/src/Log.cpp +++ b/kernel/src/Log.cpp @@ -14,11 +14,17 @@ static constexpr u32 WHITE = 0xffffffff; static constexpr u32 YELLOW = 0xffffff00; static constexpr u32 RED = 0xffff0000; -static Result log_serial(LogLevel, const char* format, va_list origin) +static char log_level_letters[] = {'D', 'I', 'W', 'E'}; // D for debug, I for info, W for warning, E for error +static const char* ansi_color_codes_per_log_level[] = {"37", "37", "33", "31"}; // 37 is white, 33 yellow, 31 red + +static Result log_serial(LogLevel level, const char* format, va_list origin) { va_list ap; va_copy(ap, origin); + TRY(Serial::printf("\x1b[%sm%c\x1b[0m ", ansi_color_codes_per_log_level[(int)level], + log_level_letters[(int)level])); + TRY(Serial::printf("[%6zu.%.6zu] ", Timer::ticks(), Timer::ticks_us() - (Timer::ticks() * 1000000))); TRY(cstyle_format(