mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-04 10:20:24 +00:00
Make log_file_info() use variadic templates.
This commit is contained in:
parent
f4b91ecaf0
commit
d173c2c51f
2 changed files with 11 additions and 17 deletions
|
@ -202,13 +202,6 @@ static void logv_string(std::string_view format, std::string str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logv(const char *format, va_list ap)
|
|
||||||
{
|
|
||||||
if (log_make_debug && !ys_debug(1))
|
|
||||||
return;
|
|
||||||
logv_string(format, vstringf(format, ap));
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_formatted_string(std::string_view format, std::string str)
|
void log_formatted_string(std::string_view format, std::string str)
|
||||||
{
|
{
|
||||||
if (log_make_debug && !ys_debug(1))
|
if (log_make_debug && !ys_debug(1))
|
||||||
|
@ -315,15 +308,9 @@ void log_formatted_file_warning(std::string_view filename, int lineno, std::stri
|
||||||
log_formatted_warning(prefix, std::move(str));
|
log_formatted_warning(prefix, std::move(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_file_info(const std::string &filename, int lineno,
|
void log_formatted_file_info(std::string_view filename, int lineno, std::string str)
|
||||||
const char *format, ...)
|
|
||||||
{
|
{
|
||||||
va_list ap;
|
log("%s:%d: Info: %s", filename, lineno, str);
|
||||||
va_start(ap, format);
|
|
||||||
std::string fmt = stringf("%s:%d: Info: %s",
|
|
||||||
filename.c_str(), lineno, format);
|
|
||||||
logv(fmt.c_str(), ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn]]
|
||||||
|
|
11
kernel/log.h
11
kernel/log.h
|
@ -124,8 +124,6 @@ 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));
|
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);
|
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_file_info(const std::string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
|
||||||
|
|
||||||
[[noreturn]] void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
[[noreturn]] void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||||
[[noreturn]] void log_file_error(const string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
[[noreturn]] void log_file_error(const string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
||||||
[[noreturn]] void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
[[noreturn]] void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||||
|
@ -175,6 +173,15 @@ void log_file_warning(std::string_view filename, int lineno, FmtString<TypeIdent
|
||||||
log_formatted_file_warning(filename, lineno, fmt.format(args...));
|
log_formatted_file_warning(filename, lineno, fmt.format(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log_formatted_file_info(std::string_view filename, int lineno, std::string str);
|
||||||
|
template <typename... Args>
|
||||||
|
void log_file_info(std::string_view filename, int lineno, FmtString<TypeIdentity<Args>...> fmt, Args... args)
|
||||||
|
{
|
||||||
|
if (log_make_debug && !ys_debug(1))
|
||||||
|
return;
|
||||||
|
log_formatted_file_info(filename, lineno, fmt.format(args...));
|
||||||
|
}
|
||||||
|
|
||||||
static inline void log_suppressed() {
|
static inline void log_suppressed() {
|
||||||
if (log_debug_suppressed && !log_make_debug) {
|
if (log_debug_suppressed && !log_make_debug) {
|
||||||
log("<suppressed ~%d debug messages>\n", log_debug_suppressed);
|
log("<suppressed ~%d debug messages>\n", log_debug_suppressed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue