]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: add a new message directive: .diag
authorWilly Tarreau <w@1wt.eu>
Fri, 7 May 2021 06:59:50 +0000 (08:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 May 2021 07:06:40 +0000 (09:06 +0200)
This one works just like .notice/.warning/.alert except that it prints
the message at level "DIAG" only when haproxy runs in diagnostic mode
(-dD). This can be convenient for example to pass a few hints to help
locate certain config parts or to leave messages about certain temporary
workarounds.

Example:

  .diag "WTA/2021-05-07: $.LINE: replace 'redirect' with 'return' after final switch to 2.4"
         http-request redirect location /goaway if ABUSE

doc/configuration.txt
src/cfgparse.c

index 72c4680b1b6f3814fd0de3446fe540a88dd762b0..e37f84cf6b05beb43ae260a7603a522529cf10e1 100644 (file)
@@ -853,8 +853,9 @@ Example:
        profiling.memory on
    .endif
 
-Three other directives are provided to report some status:
+Four other directives are provided to report some status:
 
+  - .diag "message"    : emit this message only when in diagnostic mode (-dD)
   - .notice "message"  : emit this message at level NOTICE
   - .warning "message" : emit this message at level WARNING
   - .alert "message"   : emit this message at level ALERT
@@ -880,6 +881,9 @@ Example:
        .notice "A=0"
   .endif
 
+  .diag "WTA/2021-05-07: replace 'redirect' with 'return' after switch to 2.4"
+        http-request redirect location /goaway if ABUSE
+
 
 2.5. Time format
 ----------------
index dead21d8c19e3345dcd8a9c6273f30380889ad31..af727440bd45c4279687c94286a6b0f99f98718b 100644 (file)
@@ -2136,7 +2136,7 @@ next_line:
                        goto next_line;
                }
 
-               /* .warning/.error/.notice */
+               /* .warning/.error/.notice/.diag */
                if (*args[0] == '.') {
                        if (strcmp(args[0], ".alert") == 0) {
                                ha_alert("parsing [%s:%d]: '%s'.\n", file, linenum, args[1]);
@@ -2152,6 +2152,10 @@ next_line:
                                ha_notice("parsing [%s:%d]: '%s'.\n", file, linenum, args[1]);
                                goto next_line;
                        }
+                       else if (strcmp(args[0], ".diag") == 0) {
+                               ha_diag_warning("parsing [%s:%d]: '%s'.\n", file, linenum, args[1]);
+                               goto next_line;
+                       }
                        else {
                                ha_alert("parsing [%s:%d]: unknown directive '%s'.\n", file, linenum, args[0]);
                                err_code |= ERR_ALERT | ERR_FATAL;