From 709e780fe7e657caa727647b0fff46d976792110 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 24 Sep 2026 09:05:39 +0200 Subject: [PATCH] logger: add highlighted text and fix formatting --- kernel/driver.cc | 10 ++++++++-- kernel/log.h | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kernel/driver.cc b/kernel/driver.cc index a26724b76..996789ff7 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -169,7 +169,7 @@ void ColorConsoleLogSink::log(const LogMessage &msg) next_print_log = false; } - if (next_print_log && !msg.src.filename.empty()) + if (!msg.src.filename.empty()) fmt::print(f, fg(fmt::terminal_color::bright_cyan), "{}:{}: ", msg.src.filename, msg.src.start_line); switch (msg.severity) { @@ -189,6 +189,10 @@ void ColorConsoleLogSink::log(const LogMessage &msg) fmt::print(f, fg(fmt::terminal_color::white) | fmt::emphasis::bold, "{}", msg.message); break; + case LogSeverity::Highlight: + fmt::print(f, fg(fmt::terminal_color::cyan) | fmt::emphasis::bold, "{}{}", msg.prefix, msg.message); + break; + case LogSeverity::Comment: case LogSeverity::Debug: fmt::print(f, fg(fmt::terminal_color::bright_black), "{}{}", msg.prefix, msg.message); @@ -196,7 +200,9 @@ void ColorConsoleLogSink::log(const LogMessage &msg) case LogSeverity::Info: default: - fmt::print(f, "{}{}", msg.prefix, msg.message); + if (!msg.prefix.empty()) + fmt::print(f, fg(fmt::terminal_color::bright_black), "{}", msg.prefix); + fmt::print(f, "{}", msg.message); break; } if (!msg.message.empty()) diff --git a/kernel/log.h b/kernel/log.h index 71971e2ee..451ba4e04 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -90,6 +90,7 @@ enum class LogSeverity { Debug, Comment, Info, + Highlight, Header, Warning, NonFatalError, @@ -492,6 +493,12 @@ inline void log_comment(FmtString...> fmt, const Args &... ar logger().formatted_string(LogSeverity::Comment, LogSourceLocation{}, {}, fmt.format_string(), fmt.format(args...)); } +template +inline void log_highlight(FmtString...> fmt, const Args &... args) +{ + logger().formatted_string(LogSeverity::Highlight, LogSourceLocation{}, {}, fmt.format_string(), fmt.format(args...)); +} + template inline void log_formatted_string(LogSeverity severity, LogSourceLocation src, std::string_view prefix, FmtString...> fmt, const Args &... args) @@ -539,7 +546,7 @@ void log_file_warning(LogSourceLocation src, FmtString...> fm template void log_file_info(LogSourceLocation src, FmtString...> fmt, const Args &... args) { - logger().formatted_string(LogSeverity::Info, src, "Info: ", fmt.format_string(), fmt.format(args...)); + logger().formatted_string(LogSeverity::Info, src, "NOTE: ", fmt.format_string(), fmt.format(args...)); } template