From 3318339befaee6c57c3ac3b009822633ebb20f61 Mon Sep 17 00:00:00 2001 From: ekwongchum Date: Thu, 7 Jul 2022 11:33:18 +0800 Subject: [PATCH 1/2] out_file: allow appending content to out file in same line Signed-off-by: ekwongchum --- plugins/out_file/file.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/out_file/file.c b/plugins/out_file/file.c index 3539b507b36..ec509529f07 100644 --- a/plugins/out_file/file.c +++ b/plugins/out_file/file.c @@ -53,6 +53,7 @@ struct flb_file_conf { int format; int csv_column_names; int mkdir; + int line_append; struct flb_output_instance *ins; }; @@ -97,6 +98,7 @@ static int cb_file_init(struct flb_output_instance *ins, ctx->delimiter = NULL; ctx->label_delimiter = NULL; ctx->template = NULL; + ctx->line_append = FLB_FALSE; ret = flb_output_config_map_set(ins, (void *) ctx); if (ret == -1) { @@ -316,7 +318,9 @@ static int template_output(FILE *fp, struct flb_time *tm, msgpack_object *obj, if (inbrace) { fputs(inbrace, fp); } - fputs(NEWLINE, fp); + if (ctx->line_append == FLB_FALSE){ + fputs(NEWLINE, fp); + } return 0; } @@ -636,6 +640,12 @@ static struct flb_config_map config_map[] = { "Recursively create output directory if it does not exist. Permissions set to 0755" }, + { + FLB_CONFIG_MAP_BOOL, "line_append", "false", + 0, FLB_TRUE, offsetof(struct flb_file_conf, line_append), + "Append new data to the end of log in same line. Default value is false" + }, + /* EOF */ {0} }; From d7562297a2f7bfa16578eedc53cc4460c69ae931 Mon Sep 17 00:00:00 2001 From: ekwongchum Date: Wed, 20 Jul 2022 15:19:09 +0800 Subject: [PATCH 2/2] out_file: update tips about config > Co-authored-by: Pat Signed-off-by: ekwongchum --- plugins/out_file/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_file/file.c b/plugins/out_file/file.c index ec509529f07..d043089b42a 100644 --- a/plugins/out_file/file.c +++ b/plugins/out_file/file.c @@ -643,7 +643,7 @@ static struct flb_config_map config_map[] = { { FLB_CONFIG_MAP_BOOL, "line_append", "false", 0, FLB_TRUE, offsetof(struct flb_file_conf, line_append), - "Append new data to the end of log in same line. Default value is false" + "Append data to the existing line rather than start a new line. Default value is false, use embedded new line characters '\n' to create new lines if true otherwise all output will be on a single line." }, /* EOF */