]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: split do_log() in do_log() + do_log_ctx()
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 19 Mar 2026 11:54:23 +0000 (12:54 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 20 Mar 2026 10:41:06 +0000 (11:41 +0100)
do_log() is just a wrapper to use do_log_ctx() with pre-filled ctx, but
we now have the low-level do_log_ctx() variant which can be used to
pass specific ctx parameters instead.

src/log.c

index f26079b22b7934f0eb209bab2835e6592a49bad8..22c300bd71765b38cd6ce3e4db17b9d8260a3285 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -5200,17 +5200,11 @@ out:
 
 }
 
-/*
- * opportunistic log when at least the session is known to exist
- * <s> may be NULL
- *
- * Will not log if the frontend has no log defined. By default it will
- * try to emit the log as INFO, unless the stream already exists and
- * set-log-level was used.
- */
-void do_log(struct session *sess, struct stream *s, struct log_orig origin)
+static void do_log_ctx(struct process_send_log_ctx *ctx)
 {
-       struct process_send_log_ctx ctx;
+       struct stream *s = ctx->stream;
+       struct session *sess = ctx->sess;
+       struct log_orig origin = ctx->origin;
        int size;
        int sd_size = 0;
        int level = -1;
@@ -5242,11 +5236,26 @@ void do_log(struct session *sess, struct stream *s, struct log_orig origin)
 
        size = sess_build_logline_orig(sess, s, logline, global.max_syslog_len, &sess->fe->logformat, origin);
 
+       __send_log(ctx, &sess->fe->loggers, &sess->fe->log_tag, level,
+                  logline, size, logline_rfc5424, sd_size);
+}
+
+/*
+ * opportunistic log when at least the session is known to exist
+ * <s> may be NULL
+ *
+ * Will not log if the frontend has no log defined. By default it will
+ * try to emit the log as INFO, unless the stream already exists and
+ * set-log-level was used.
+ */
+void do_log(struct session *sess, struct stream *s, struct log_orig origin)
+{
+       struct process_send_log_ctx ctx;
+
        ctx.origin = origin;
        ctx.sess = sess;
        ctx.stream = s;
-       __send_log(&ctx, &sess->fe->loggers, &sess->fe->log_tag, level,
-                  logline, size, logline_rfc5424, sd_size);
+       do_log_ctx(&ctx);
 }
 
 /*