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().
This commit is contained in:
William Lallemand 2023-11-09 14:18:27 +01:00
parent 59d699c0c4
commit da24b462c3

View File

@ -404,9 +404,10 @@ static void print_message(int use_usermsgs_ctx, const char *label, const char *f
else {
usermsgs_put(&msg_ist);
}
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,20 +438,17 @@ 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);
}
}
/*
* Displays the message on stderr with the pid.
@ -462,13 +460,11 @@ 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);
}
}
/*
* Variant of _ha_diag_warning with va_list.
@ -513,12 +509,10 @@ 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);
}
}
/*
* Displays the message on <out> only if quiet mode is not set.