]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: add __send_log_set_metadata_sd helper
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 23 May 2024 13:58:59 +0000 (15:58 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 13 Jun 2024 13:43:09 +0000 (15:43 +0200)
Extract sd metadata assignment in __send_log() to make an inline helper
function out of it in order to be able to use it from other functions if
needed.

src/log.c

index 974795319daacc582a6a8cb0e53519812ca901c6..cee65110244e7f3d8328989caad8849b21316a10 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2774,6 +2774,15 @@ static inline void __do_send_log_backend(struct proxy *be, struct log_header hdr
        _HA_ATOMIC_INC(&dropped_logs);
 }
 
+static inline void __send_log_set_metadata_sd(struct ist *metadata, char *sd, size_t sd_size)
+{
+       metadata[LOG_META_STDATA] = ist2(sd, sd_size);
+
+       /* Remove trailing space of structured data */
+       while (metadata[LOG_META_STDATA].len && metadata[LOG_META_STDATA].ptr[metadata[LOG_META_STDATA].len-1] == ' ')
+               metadata[LOG_META_STDATA].len--;
+}
+
 /* provided to low-level process_send_log() helper, may be NULL */
 struct process_send_log_ctx {
        struct session *sess;
@@ -2892,11 +2901,7 @@ static void __send_log(struct process_send_log_ctx *ctx,
                metadata[LOG_META_PID] = ist2(pidstr, strlen(pidstr));
        }
 
-       metadata[LOG_META_STDATA] = ist2(sd, sd_size);
-
-       /* Remove trailing space of structured data */
-       while (metadata[LOG_META_STDATA].len && metadata[LOG_META_STDATA].ptr[metadata[LOG_META_STDATA].len-1] == ' ')
-               metadata[LOG_META_STDATA].len--;
+       __send_log_set_metadata_sd(metadata, sd, sd_size);
 
        return process_send_log(ctx, loggers, level, -1, metadata, message, size);
 }