diff --git a/kernel/log.cc b/kernel/log.cc index 8f9ee2a13..5fda6ce14 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -309,15 +309,10 @@ void log_formatted_warning(std::string_view prefix, std::string message) } } -void log_file_warning(const std::string &filename, int lineno, - const char *format, ...) +void log_formatted_file_warning(std::string_view filename, int lineno, std::string str) { - va_list ap; - va_start(ap, format); - std::string prefix = stringf("%s:%d: Warning: ", - filename.c_str(), lineno); - log_formatted_warning(prefix, vstringf(format, ap)); - va_end(ap); + std::string prefix = stringf("%s:%d: Warning: ", filename, lineno); + log_formatted_warning(prefix, std::move(str)); } void log_file_info(const std::string &filename, int lineno, diff --git a/kernel/log.h b/kernel/log.h index ba2c1d9dc..bdada8437 100644 --- a/kernel/log.h +++ b/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)); 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); -// Log with filename to report a problem in a source file. -void log_file_warning(const std::string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4)); 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)); @@ -169,6 +167,14 @@ inline void log_warning_noprefix(FmtString...> fmt, Args... a void log_experimental(const std::string &str); +// Log with filename to report a problem in a source file. +void log_formatted_file_warning(std::string_view filename, int lineno, std::string str); +template +void log_file_warning(std::string_view filename, int lineno, FmtString...> fmt, Args... args) +{ + log_formatted_file_warning(filename, lineno, fmt.format(args...)); +} + static inline void log_suppressed() { if (log_debug_suppressed && !log_make_debug) { log("\n", log_debug_suppressed);