]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: errors: move the MODE_QUIET test in print_message()
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 9 Nov 2023 13:18:27 +0000 (14:18 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 9 Nov 2023 13:39:11 +0000 (14:39 +0100)
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

index 8e3bc5b010e313d9b1d8a42b65d239c401816f3d..e30f21ef28e4b43daa5281f59a57ab0acd8d6094 100644 (file)
@@ -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);
 }
 
 /*