mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
fluent-bit: Align syslog output with syslog-ng
- added support to prepend message length in syslog output
This commit is contained in:
parent
7227cbd8da
commit
09cccc39cc
1 changed files with 47 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
diff --git a/plugins/out_syslog/syslog.c b/plugins/out_syslog/syslog.c
|
||||
index 4ecc7c4ac..cfe568245 100644
|
||||
--- a/plugins/out_syslog/syslog.c
|
||||
+++ b/plugins/out_syslog/syslog.c
|
||||
@@ -776,12 +776,42 @@ static flb_sds_t syslog_format(struct flb_syslog *ctx, msgpack_object *o,
|
||||
}
|
||||
|
||||
if (ctx->parsed_mode != FLB_SYSLOG_UDP) {
|
||||
+ unsigned int msg_len = 0;
|
||||
+
|
||||
+ /* Create new SDS for length prefix */
|
||||
+ flb_sds_t prefix = flb_sds_create_size(ctx->maxsize + 32);
|
||||
+ if (!prefix) {
|
||||
+ ret_sds = NULL;
|
||||
+ goto clean;
|
||||
+ }
|
||||
+
|
||||
+ /* Add newline also to make behaviour similar to syslog-ng */
|
||||
tmp = flb_sds_cat(*s, "\n", 1);
|
||||
if (!tmp) {
|
||||
+ flb_sds_destroy(prefix);
|
||||
ret_sds = NULL;
|
||||
goto clean;
|
||||
}
|
||||
*s = tmp;
|
||||
+
|
||||
+ msg_len = flb_sds_len(*s);
|
||||
+ tmp = flb_sds_printf(&prefix, "%u ", msg_len);
|
||||
+ if (!tmp) {
|
||||
+ flb_sds_destroy(prefix);
|
||||
+ ret_sds = NULL;
|
||||
+ goto clean;
|
||||
+ }
|
||||
+ prefix = tmp;
|
||||
+
|
||||
+ tmp = flb_sds_cat(prefix, *s, msg_len);
|
||||
+ if (!tmp) {
|
||||
+ flb_sds_destroy(prefix);
|
||||
+ ret_sds = NULL;
|
||||
+ goto clean;
|
||||
+ }
|
||||
+
|
||||
+ flb_sds_destroy(*s);
|
||||
+ *s = tmp;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Loading…
Add table
Reference in a new issue