]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: errors: add ha_diag_notice() to report diag-level notifications
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2026 16:36:17 +0000 (18:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2026 16:48:59 +0000 (18:48 +0200)
Right now the only way to report info that is only displayed in diag
mode with -dD is to use ha_diag_warning(). The problem is that this is
then counted as a warning and may result in errors when combined with
-dW, as happens for the CPU topology info:

  $ printf "global\nstats socket /tmp/sock1\n" | ./haproxy -dD -dW -c -f /dev/stdin; echo $?
  [NOTICE]   (10406) : haproxy version is 3.5-dev0-5091ac-35
  [NOTICE]   (10406) : path to executable is ./haproxy
  [DIAG]     (10406) : Created 20 threads split into 2 groups
  [ALERT]    (10406) : Some warnings were found and 'zero-warning' is set. Aborting.
  1

We need another level. This commit introduces ha_diag_notice() which only
emits a notification that doesn't count as a warning. Note that we could
even introduce an info level and revisit various messages so that notice
only reports certain events while info is for anything (like versions
above). That could be a future improvement.

include/haproxy/errors.h
src/errors.c

index c102fedb8eb70d02552db2941a65ba7f22a888d3..1fa5017249b17f6b532871fde8c1d041c3fc2041 100644 (file)
@@ -101,6 +101,8 @@ void ha_warning(const char *fmt, ...)
  * These functions are reserved to output diagnostics on MODE_DIAG.
  * Use the underscore variants only if MODE_DIAG has already been checked.
  */
+void ha_diag_notice(const char *fmt, ...)
+       __attribute__ ((format(printf, 1 ,2)));
 void _ha_vdiag_warning(const char *fmt, va_list argp);
 void _ha_diag_warning(const char *fmt, ...);
 void ha_diag_warning(const char *fmt, ...)
index f71622c0a2d9d944af554a76c0bc030cb72b55e5..9f334dbe4af239d18121a072028ffc89f91b4b1f 100644 (file)
@@ -386,6 +386,20 @@ void ha_diag_warning(const char *fmt, ...)
        }
 }
 
+/*
+ * Displays the message on stderr with the pid if MODE_DIAG is set.
+ */
+void ha_diag_notice(const char *fmt, ...)
+{
+       va_list argp;
+
+       if (global.mode & MODE_DIAG) {
+               va_start(argp, fmt);
+               print_message(1, "DIAG", fmt, argp);
+               va_end(argp);
+       }
+}
+
 /*
  * Displays the message on stderr with the pid.
  */