mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-10-06 01:53:53 +02:00
logger: add highlighted text and fix formatting
This commit is contained in:
+8
-2
@@ -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())
|
||||
|
||||
+8
-1
@@ -90,6 +90,7 @@ enum class LogSeverity {
|
||||
Debug,
|
||||
Comment,
|
||||
Info,
|
||||
Highlight,
|
||||
Header,
|
||||
Warning,
|
||||
NonFatalError,
|
||||
@@ -492,6 +493,12 @@ inline void log_comment(FmtString<TypeIdentity<Args>...> fmt, const Args &... ar
|
||||
logger().formatted_string(LogSeverity::Comment, LogSourceLocation{}, {}, fmt.format_string(), fmt.format(args...));
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void log_highlight(FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
logger().formatted_string(LogSeverity::Highlight, LogSourceLocation{}, {}, fmt.format_string(), fmt.format(args...));
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void log_formatted_string(LogSeverity severity, LogSourceLocation src, std::string_view prefix,
|
||||
FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
@@ -539,7 +546,7 @@ void log_file_warning(LogSourceLocation src, FmtString<TypeIdentity<Args>...> fm
|
||||
template <typename... Args>
|
||||
void log_file_info(LogSourceLocation src, FmtString<TypeIdentity<Args>...> 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 <typename... Args>
|
||||
|
||||
Reference in New Issue
Block a user