Skip to content
Merged
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
10 changes: 6 additions & 4 deletions src/flb_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <fluent-bit/flb_config.h>
#include <fluent-bit/flb_worker.h>
#include <fluent-bit/flb_mem.h>
#include <fluent-bit/flb_time.h>
#include <cmetrics/cmetrics.h>
#include <cmetrics/cmt_counter.h>

Expand Down Expand Up @@ -673,13 +674,13 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
int ret;
int len;
int total;
time_t now;
const char *header_color = NULL;
const char *header_title;
const char *bold_color = ANSI_BOLD;
const char *reset_color = ANSI_RESET;
struct tm result;
struct tm *current;
struct flb_time now;

switch (type) {
case FLB_LOG_HELP:
Expand Down Expand Up @@ -718,16 +719,16 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
}
#endif // FLB_LOG_NO_CONTROL_CHARS

now = time(NULL);
current = localtime_r(&now, &result);
flb_time_get(&now);
current = localtime_r(&now.tm.tv_sec, &result);

if (current == NULL) {
return -1;
}

header_title = flb_log_message_type_str(type);
len = snprintf(msg->msg, sizeof(msg->msg) - 1,
"%s[%s%i/%02i/%02i %02i:%02i:%02i%s]%s [%s%5s%s] ",
"%s[%s%i/%02i/%02i %02i:%02i:%02i.%03ld%s]%s [%s%5s%s] ",
/* time */ /* type */

/* time variables */
Expand All @@ -738,6 +739,7 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
current->tm_hour,
current->tm_min,
current->tm_sec,
now.tm.tv_nsec,
bold_color, reset_color,

/* type format */
Expand Down
Loading