diff --git a/common/messages.c b/common/messages.c index f2efec31..2d9d55c0 100644 --- a/common/messages.c +++ b/common/messages.c @@ -151,3 +151,21 @@ void error_msg(enum common_error error, const char *msg, ...) fprintf(stderr, PREFIX_ERROR "%s\n", str); } } + +/* + * Print a message according to the global verbosity level - to stderr. + * + * level: minimum verbose level at which the message will be printed + */ +__attribute__ ((format (printf, 2, 3))) +void pr_stderr(int level, const char *fmt, ...) +{ + va_list args; + + if (!should_print(level)) + return; + + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); +} diff --git a/common/messages.h b/common/messages.h index 7ccac116..da97c045 100644 --- a/common/messages.h +++ b/common/messages.h @@ -130,6 +130,9 @@ void internal_error(const char *fmt, ...); __attribute__ ((format (printf, 2, 3))) void pr_verbose(int level, const char *fmt, ...); +__attribute__ ((format (printf, 2, 3))) +void pr_stderr(int level, const char *fmt, ...); + /* * Commonly used errors */