diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 05d853b95..5d831e25a 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -139,28 +139,18 @@ const char *get_message_type(msg_type_t msg_type) void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefile, const char *msg, va_list args) { std::string id = message_id ? stringf("[%s] ",message_id) : ""; + string message = stringf("%s%s\n", id, vstringf(msg, args)); + auto src = !linefile ? LogSourceLocation{} : LogSourceLocation{LineFile::GetFileName(linefile), +#ifdef VERIFIC_LINEFILE_INCLUDES_COLUMNS + int(linefile->GetLeftLine()), int(linefile->GetLeftCol()), int(linefile->GetRightLine()), int(linefile->GetRightCol())}; +#else + int(LineFile::GetLineNo(linefile))}; +#endif + 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", 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, - linefile ? linefile->GetRightLine() : 0, linefile ? linefile->GetRightCol() : 0, full_message.c_str()); -#else - log_verific_callback(int(msg_type), message_id, LineFile::GetFileName(linefile), - linefile ? LineFile::GetLineNo(linefile) : 0, 0, - linefile ? LineFile::GetLineNo(linefile) : 0, 0, full_message.c_str()); -#endif + log_verific_callback(int(msg_type), message_id, src, message.c_str()); } else { - auto src = !linefile ? LogSourceLocation{} : LogSourceLocation{LineFile::GetFileName(linefile), -#ifdef VERIFIC_LINEFILE_INCLUDES_COLUMNS - int(linefile->GetLeftLine()), int(linefile->GetLeftCol()), int(linefile->GetRightLine()), int(linefile->GetRightCol())}; -#else - int(LineFile::GetLineNo(linefile))}; -#endif 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); } else if (msg_type == VERIFIC_WARNING) { @@ -173,7 +163,7 @@ void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefil verific_error_msg = "Design elaboration failed; see full log for details"; } -void set_verific_logging(void (*cb)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg)) +void set_verific_logging(void (*cb)(int msg_type, const char *message_id, LogSourceLocation src, const char *msg)) { Message::SetConsoleOutput(0); Message::RegisterCallBackMsg(msg_func); diff --git a/kernel/log.cc b/kernel/log.cc index 08b4c7db0..a8f4c814a 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -52,8 +52,8 @@ std::chrono::steady_clock::time_point LogManager::get_initial_time() const return initial_time; } -void (*log_error_atexit)() = NULL; -void (*log_verific_callback)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg) = NULL; +void (*log_error_atexit)() = nullptr; +void (*log_verific_callback)(int msg_type, const char *message_id, LogSourceLocation src, const char *msg) = nullptr; // TODO: remove when log_id is removed vector log_id_cache; diff --git a/kernel/log.h b/kernel/log.h index 8b8232e1c..71971e2ee 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -471,8 +471,8 @@ LogManager &logger(); extern void (*log_error_atexit)(); -void set_verific_logging(void (*cb)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg)); -extern void (*log_verific_callback)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg); +void set_verific_logging(void (*cb)(int msg_type, const char *message_id, LogSourceLocation src, const char *msg)); +extern void (*log_verific_callback)(int msg_type, const char *message_id, LogSourceLocation src, const char *msg); #ifndef NDEBUG static inline bool ys_debug(int n = 0) { return logger().is_debug(n); }