Skip to content

Commit 3318339

Browse files
author
ekwongchum
committed
out_file: allow appending content to out file in same line
Signed-off-by: ekwongchum <[email protected]>
1 parent 4653b3f commit 3318339

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugins/out_file/file.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct flb_file_conf {
5353
int format;
5454
int csv_column_names;
5555
int mkdir;
56+
int line_append;
5657
struct flb_output_instance *ins;
5758
};
5859

@@ -97,6 +98,7 @@ static int cb_file_init(struct flb_output_instance *ins,
9798
ctx->delimiter = NULL;
9899
ctx->label_delimiter = NULL;
99100
ctx->template = NULL;
101+
ctx->line_append = FLB_FALSE;
100102

101103
ret = flb_output_config_map_set(ins, (void *) ctx);
102104
if (ret == -1) {
@@ -316,7 +318,9 @@ static int template_output(FILE *fp, struct flb_time *tm, msgpack_object *obj,
316318
if (inbrace) {
317319
fputs(inbrace, fp);
318320
}
319-
fputs(NEWLINE, fp);
321+
if (ctx->line_append == FLB_FALSE){
322+
fputs(NEWLINE, fp);
323+
}
320324
return 0;
321325
}
322326

@@ -636,6 +640,12 @@ static struct flb_config_map config_map[] = {
636640
"Recursively create output directory if it does not exist. Permissions set to 0755"
637641
},
638642

643+
{
644+
FLB_CONFIG_MAP_BOOL, "line_append", "false",
645+
0, FLB_TRUE, offsetof(struct flb_file_conf, line_append),
646+
"Append new data to the end of log in same line. Default value is false"
647+
},
648+
639649
/* EOF */
640650
{0}
641651
};

0 commit comments

Comments
 (0)