Skip to content

Commit aa04fc2

Browse files
author
ekwongchum
committed
new property to control output file append in line
Signed-off-by: ekwongchum <[email protected]>
1 parent 4653b3f commit aa04fc2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

plugins/out_file/file.c

Lines changed: 18 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 = 0;
100102

101103
ret = flb_output_config_map_set(ins, (void *) ctx);
102104
if (ret == -1) {
@@ -152,6 +154,13 @@ static int cb_file_init(struct flb_output_instance *ins,
152154
ctx->label_delimiter = ret_str;
153155
}
154156

157+
tmp = flb_output_get_property("line_append", ins);
158+
if (tmp) {
159+
if (!strcasecmp(tmp, "true")) {
160+
ctx->line_append = 1;
161+
}
162+
}
163+
155164
/* Set the context */
156165
flb_output_set_context(ins, ctx);
157166

@@ -316,7 +325,9 @@ static int template_output(FILE *fp, struct flb_time *tm, msgpack_object *obj,
316325
if (inbrace) {
317326
fputs(inbrace, fp);
318327
}
319-
fputs(NEWLINE, fp);
328+
if (ctx->line_append == 0){
329+
fputs(NEWLINE, fp);
330+
}
320331
return 0;
321332
}
322333

@@ -636,6 +647,12 @@ static struct flb_config_map config_map[] = {
636647
"Recursively create output directory if it does not exist. Permissions set to 0755"
637648
},
638649

650+
{
651+
FLB_CONFIG_MAP_BOOL, "line_append", "false",
652+
0, FLB_TRUE, offsetof(struct flb_file_conf, line_append),
653+
"Append new data to the end off log in same line. Default value is false"
654+
},
655+
639656
/* EOF */
640657
{0}
641658
};

0 commit comments

Comments
 (0)