Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/fluent-bit/flb_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define FLB_PACK_JSON_DATE_ISO8601 1
#define FLB_PACK_JSON_DATE_EPOCH 2
#define FLB_PACK_JSON_DATE_JAVA_SQL_TIMESTAMP 3
#define FLB_PACK_JSON_DATE_EPOCH_MS 4

/* Specific ISO8601 format */
#define FLB_PACK_JSON_DATE_ISO8601_FMT "%Y-%m-%dT%H:%M:%S"
Expand Down
10 changes: 10 additions & 0 deletions src/flb_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,11 @@ int flb_pack_to_json_date_type(const char *str)
else if (strcasecmp(str, "epoch") == 0) {
return FLB_PACK_JSON_DATE_EPOCH;
}
else if (strcasecmp(str, "epoch_ms") == 0 ||
strcasecmp(str, "epoch_millis") == 0 ||
strcasecmp(str, "epoch_milliseconds") == 0) {
return FLB_PACK_JSON_DATE_EPOCH_MS;
}

return -1;
}
Expand Down Expand Up @@ -951,6 +956,11 @@ flb_sds_t flb_pack_msgpack_to_json_format(const char *data, uint64_t bytes,
case FLB_PACK_JSON_DATE_EPOCH:
msgpack_pack_uint64(&tmp_pck, (long long unsigned)(tms.tm.tv_sec));
break;
case FLB_PACK_JSON_DATE_EPOCH_MS:
msgpack_pack_uint64(&tmp_pck,
(long long unsigned)(tms.tm.tv_sec) * 1000 +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create the function flb_time_to_millisec in flb_time.c and move that conversion there so it can be reused by others in the future? Also, please use uint64_t like flb_time_to_nanosec.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeongki-kim Could you make these changes, please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. Had I found this earlier, I'd have followed your suggestion.

tms.tm.tv_nsec / 1000000);
break;
}
}

Expand Down