From a1c8bda52a9c07d32127762ee0c865660a0268ab Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 2 Jun 2020 15:39:19 -0400 Subject: diag: Unify debug printing --- diag.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'diag.h') diff --git a/diag.h b/diag.h index 54f2366..2e5513e 100644 --- a/diag.h +++ b/diag.h @@ -24,6 +24,7 @@ #include "cmdline.h" #include "util.h" #include +#include /** * Shorthand for printing error messages. @@ -33,9 +34,19 @@ void bfs_error(const struct cmdline *cmdline, const char *format, ...); /** * Shorthand for printing warning messages. + * + * @return Whether a warning was printed. */ BFS_FORMATTER(2, 3) -void bfs_warning(const struct cmdline *cmdline, const char *format, ...); +bool bfs_warning(const struct cmdline *cmdline, const char *format, ...); + +/** + * Shorthand for printing debug messages. + * + * @return Whether a debug message was printed. + */ +BFS_FORMATTER(3, 4) +bool bfs_debug(const struct cmdline *cmdline, enum debug_flags flag, const char *format, ...); /** * bfs_error() variant that takes a va_list. @@ -45,7 +56,12 @@ void bfs_verror(const struct cmdline *cmdline, const char *format, va_list args) /** * bfs_warning() variant that takes a va_list. */ -void bfs_vwarning(const struct cmdline *cmdline, const char *format, va_list args); +bool bfs_vwarning(const struct cmdline *cmdline, const char *format, va_list args); + +/** + * bfs_debug() variant that takes a va_list. + */ +bool bfs_vdebug(const struct cmdline *cmdline, enum debug_flags flag, const char *format, va_list args); /** * Print the error message prefix. @@ -55,6 +71,11 @@ void bfs_error_prefix(const struct cmdline *cmdline); /** * Print the warning message prefix. */ -void bfs_warning_prefix(const struct cmdline *cmdline); +bool bfs_warning_prefix(const struct cmdline *cmdline); + +/** + * Print the debug message prefix. + */ +bool bfs_debug_prefix(const struct cmdline *cmdline, enum debug_flags flag); #endif // BFS_DIAG_H -- cgit v1.2.3