mirror of
https://github.com/YosysHQ/yosys
synced 2026-08-14 09:55:37 +00:00
log: make it so we can reuse default one
This commit is contained in:
parent
5289638228
commit
982084515c
2 changed files with 28 additions and 22 deletions
|
|
@ -83,8 +83,28 @@ static void log_id_cache_clear()
|
|||
log_id_cache.clear();
|
||||
}
|
||||
|
||||
void log_colored_callback(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity)
|
||||
void log_default_callback(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity, bool skip_std)
|
||||
{
|
||||
(void)severity;
|
||||
std::string str = stringf("%s%s%s",time_str,prefix,msg);
|
||||
for (auto f : log_files) {
|
||||
if (skip_std && (f==stderr || f==stdout))
|
||||
continue;
|
||||
fputs(str.c_str(), f);
|
||||
}
|
||||
|
||||
for (auto f : log_streams)
|
||||
*f << str;
|
||||
|
||||
RTLIL::Design *design = yosys_get_design();
|
||||
if (design != nullptr)
|
||||
for (auto &scratchpad : log_scratchpads)
|
||||
design->scratchpad[scratchpad].append(str);
|
||||
}
|
||||
|
||||
void log_colored_callback(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity, bool skip_std)
|
||||
{
|
||||
(void)skip_std;
|
||||
if (!time_str.empty())
|
||||
fmt::print(fg(fmt::terminal_color::blue), "{}", time_str);
|
||||
|
||||
|
|
@ -112,21 +132,12 @@ void log_colored_callback(std::string_view time_str, std::string_view prefix, st
|
|||
default:
|
||||
fmt::print("{}{}", prefix, msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
log_default_callback(time_str, prefix, msg, severity, true);
|
||||
}
|
||||
|
||||
void log_default_callback(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity)
|
||||
{
|
||||
(void)severity;
|
||||
std::string str = stringf("%s%s%s",time_str,prefix,msg);
|
||||
for (auto f : log_files)
|
||||
fputs(str.c_str(), f);
|
||||
|
||||
for (auto f : log_streams)
|
||||
*f << str;
|
||||
}
|
||||
|
||||
void (*log_callback)(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity) = log_default_callback;
|
||||
void (*log_callback)(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity, bool skip_std) = log_default_callback;
|
||||
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
|
|
@ -201,12 +212,7 @@ static void logv_string(std::string_view prefix, std::string_view format, std::s
|
|||
if (format == "%s" && str.back() == '\n')
|
||||
next_print_log = true;
|
||||
}
|
||||
log_callback(time_str, prefix, strin, severity);
|
||||
|
||||
RTLIL::Design *design = yosys_get_design();
|
||||
if (design != nullptr)
|
||||
for (auto &scratchpad : log_scratchpads)
|
||||
design->scratchpad[scratchpad].append(str);
|
||||
log_callback(time_str, prefix, strin, severity, false);
|
||||
|
||||
static std::string linebuffer;
|
||||
static bool log_warn_regex_recusion_guard = false;
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ extern int log_debug_suppressed;
|
|||
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 log_default_callback(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity);
|
||||
extern void (*log_callback)(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity);
|
||||
void log_default_callback(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity, bool skip_std);
|
||||
extern void (*log_callback)(std::string_view time_str, std::string_view prefix, std::string_view msg, LogSeverity severity, bool skip_std);
|
||||
|
||||
#ifndef NDEBUG
|
||||
static inline bool ys_debug(int n = 0) { if (log_force_debug) return true; log_debug_suppressed += n; return false; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue