Skip to content

Commit c745241

Browse files
committed
out_stdout: support 'false' value to disable json_date_key
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 25b722d commit c745241

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugins/out_stdout/stdout.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ static int cb_stdout_init(struct flb_output_instance *ins,
6464
}
6565
}
6666

67+
/* Date key */
68+
ctx->date_key = ctx->json_date_key;
69+
tmp = flb_output_get_property("json_date_key", ins);
70+
if (tmp) {
71+
/* Just check if we have to disable it */
72+
if (flb_utils_bool(tmp) == FLB_FALSE) {
73+
ctx->date_key = NULL;
74+
}
75+
}
76+
6777
/* Date format for JSON output */
6878
ctx->json_date_format = FLB_PACK_JSON_DATE_DOUBLE;
6979
tmp = flb_output_get_property("json_date_format", ins);
@@ -104,7 +114,7 @@ static void cb_stdout_flush(const void *data, size_t bytes,
104114
json = flb_pack_msgpack_to_json_format(data, bytes,
105115
ctx->out_format,
106116
ctx->json_date_format,
107-
ctx->json_date_key);
117+
ctx->date_key);
108118
write(STDOUT_FILENO, json, flb_sds_len(json));
109119
flb_sds_destroy(json);
110120

plugins/out_stdout/stdout.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct flb_stdout {
2828
int out_format;
2929
int json_date_format;
3030
flb_sds_t json_date_key;
31+
flb_sds_t date_key;
3132
struct flb_output_instance *ins;
3233
};
3334

0 commit comments

Comments
 (0)