mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-10-06 10:03:36 +02:00
logger: few more cleanups
This commit is contained in:
@@ -114,22 +114,35 @@ int verific_sva_fsm_limit;
|
||||
vector<string> verific_incdirs, verific_libdirs, verific_libexts;
|
||||
#endif
|
||||
|
||||
const char *get_message_type(msg_type_t msg_type)
|
||||
{
|
||||
switch (msg_type) {
|
||||
case VERIFIC_NONE:
|
||||
return "VERIFIC-NONE";
|
||||
case VERIFIC_ERROR:
|
||||
return "VERIFIC-ERROR";
|
||||
case VERIFIC_WARNING:
|
||||
return "VERIFIC-WARNING";
|
||||
case VERIFIC_IGNORE:
|
||||
return "VERIFIC-IGNORE";
|
||||
case VERIFIC_INFO:
|
||||
return "VERIFIC-INFO";
|
||||
case VERIFIC_COMMENT:
|
||||
return "VERIFIC-COMMENT";
|
||||
case VERIFIC_PROGRAM_ERROR:
|
||||
return "VERIFIC-PROGRAM_ERROR";
|
||||
default:
|
||||
return "VERIFIC-UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefile, const char *msg, va_list args)
|
||||
{
|
||||
string message_type = stringf("VERIFIC-%s",
|
||||
msg_type == VERIFIC_NONE ? "NONE" :
|
||||
msg_type == VERIFIC_ERROR ? "ERROR" :
|
||||
msg_type == VERIFIC_WARNING ? "WARNING" :
|
||||
msg_type == VERIFIC_IGNORE ? "IGNORE" :
|
||||
msg_type == VERIFIC_INFO ? "INFO" :
|
||||
msg_type == VERIFIC_COMMENT ? "COMMENT" :
|
||||
msg_type == VERIFIC_PROGRAM_ERROR ? "PROGRAM_ERROR" : "UNKNOWN");
|
||||
|
||||
std::string id = message_id ? stringf("[%s] ",message_id) : "";
|
||||
if (log_verific_callback) {
|
||||
string message = linefile ? stringf("%s:%d: ", LineFile::GetFileName(linefile), LineFile::GetLineNo(linefile)) : "";
|
||||
message += vstringf(msg, args);
|
||||
string full_message = stringf("%s [%s] %s\n", message_type, id, message);
|
||||
string full_message = stringf("%s [%s] %s\n", get_message_type(msg_type), id, message);
|
||||
#ifdef VERIFIC_LINEFILE_INCLUDES_COLUMNS
|
||||
log_verific_callback(int(msg_type), message_id, LineFile::GetFileName(linefile),
|
||||
linefile ? linefile->GetLeftLine() : 0, linefile ? linefile->GetLeftCol() : 0,
|
||||
@@ -146,7 +159,7 @@ void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefil
|
||||
#else
|
||||
int(LineFile::GetLineNo(linefile))};
|
||||
#endif
|
||||
string message_prefix = stringf("%s: ",message_type);
|
||||
string message_prefix = stringf("%s: ",get_message_type(msg_type));
|
||||
string message = stringf("%s%s\n", id, vstringf(msg, args));
|
||||
if (msg_type == VERIFIC_ERROR || msg_type == VERIFIC_PROGRAM_ERROR) {
|
||||
logger().formatted_nonfatal_error(src, message_prefix, "%s%s\n", message);
|
||||
|
||||
+11
-17
@@ -344,14 +344,14 @@ void LogManager::suppressed() {
|
||||
}
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void LogManager::formatted_error(LogSourceLocation src, std::string_view prefix, std::string_view format, std::string message)
|
||||
void LogManager::error_with_prefix(LogSeverity severity, LogSourceLocation src, std::string_view prefix, std::string_view format, std::string message)
|
||||
{
|
||||
int bak_make_debug = make_debug;
|
||||
make_debug = 0;
|
||||
suppressed();
|
||||
if (severity == LogSeverity::Error)
|
||||
suppressed();
|
||||
|
||||
formatted_string(LogSeverity::Error, src, prefix, format, message);
|
||||
formatted_string(severity, src, prefix, format, message);
|
||||
flush();
|
||||
|
||||
make_debug = bak_make_debug;
|
||||
@@ -367,6 +367,12 @@ void LogManager::formatted_error(LogSourceLocation src, std::string_view prefix,
|
||||
item.current_count++;
|
||||
|
||||
errors_count++;
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void LogManager::formatted_error(LogSourceLocation src, std::string_view prefix, std::string_view format, std::string message)
|
||||
{
|
||||
error_with_prefix(LogSeverity::Error, src, prefix, format, message);
|
||||
|
||||
check_expected();
|
||||
|
||||
@@ -387,19 +393,7 @@ void LogManager::formatted_error(LogSourceLocation src, std::string_view prefix,
|
||||
|
||||
void LogManager::formatted_nonfatal_error(LogSourceLocation src, std::string_view prefix, std::string_view format, std::string message)
|
||||
{
|
||||
formatted_string(LogSeverity::NonFatalError, src, prefix, format, message);
|
||||
|
||||
for (auto &[_, item] : expect_error)
|
||||
if (std::regex_search(message, item.pattern))
|
||||
item.current_count++;
|
||||
|
||||
std::string loc = !src.filename.empty() ? stringf("%s:%d: ", src.filename, src.start_line) : "";
|
||||
std::string pattern = loc + string(prefix) + message;
|
||||
for (auto &[_, item] : expect_prefix_error)
|
||||
if (std::regex_search(pattern, item.pattern))
|
||||
item.current_count++;
|
||||
|
||||
errors_count++;
|
||||
error_with_prefix(LogSeverity::NonFatalError, src, prefix, format, message);
|
||||
}
|
||||
|
||||
void LogManager::add_experimental(const std::string &str)
|
||||
|
||||
@@ -441,6 +441,7 @@ public:
|
||||
|
||||
private:
|
||||
void logv_string(LogSeverity severity, LogSourceLocation src, std::string_view prefix, std::string_view format, std::string str_in);
|
||||
void error_with_prefix(LogSeverity severity, LogSourceLocation src, std::string_view prefix, std::string_view format, std::string message);
|
||||
|
||||
std::vector<std::unique_ptr<LogSink>> sinks;
|
||||
int verbose_level = 0;
|
||||
|
||||
Reference in New Issue
Block a user