From da24b462c3c630654db64ee919c8f01dab50b9ec Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Thu, 9 Nov 2023 14:18:27 +0100 Subject: [PATCH] MEDIUM: errors: move the MODE_QUIET test in print_message() Move the MODE_QUIET and MODE_VERBOSE test in print_message() so we always output in the startup-logs even with MODE_QUIET. ha_warning(), ha_alert() and ha_notice() does not check the MODE_QUIET and MODE_VERBOSE anymore, it is done before doing the fprintf() in print_message(). --- src/errors.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/errors.c b/src/errors.c index 8e3bc5b01..e30f21ef2 100644 --- a/src/errors.c +++ b/src/errors.c @@ -404,9 +404,10 @@ static void print_message(int use_usermsgs_ctx, const char *label, const char *f else { usermsgs_put(&msg_ist); } - - fprintf(stderr, "%s%s%s", head, parsing_str, msg); - fflush(stderr); + if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { + fprintf(stderr, "%s%s%s", head, parsing_str, msg); + fflush(stderr); + } free(head); free(msg); @@ -437,19 +438,16 @@ static void warn_exec_path() } /* - * Displays the message on stderr with the pid. Overrides the quiet - * mode during startup. + * Displays the message on stderr with the pid. */ void ha_alert(const char *fmt, ...) { va_list argp; - if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { - warn_exec_path(); - va_start(argp, fmt); - print_message(1, "ALERT", fmt, argp); - va_end(argp); - } + warn_exec_path(); + va_start(argp, fmt); + print_message(1, "ALERT", fmt, argp); + va_end(argp); } /* @@ -462,12 +460,10 @@ void ha_warning(const char *fmt, ...) warned |= WARN_ANY; HA_ATOMIC_INC(&tot_warnings); - if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { - warn_exec_path(); - va_start(argp, fmt); - print_message(1, "WARNING", fmt, argp); - va_end(argp); - } + warn_exec_path(); + va_start(argp, fmt); + print_message(1, "WARNING", fmt, argp); + va_end(argp); } /* @@ -513,11 +509,9 @@ void ha_notice(const char *fmt, ...) { va_list argp; - if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { - va_start(argp, fmt); - print_message(1, "NOTICE", fmt, argp); - va_end(argp); - } + va_start(argp, fmt); + print_message(1, "NOTICE", fmt, argp); + va_end(argp); } /*