3232#include <fluent-bit/flb_config.h>
3333#include <fluent-bit/flb_worker.h>
3434#include <fluent-bit/flb_mem.h>
35+ #include <fluent-bit/flb_time.h>
3536#include <cmetrics/cmetrics.h>
3637#include <cmetrics/cmt_counter.h>
3738
@@ -673,13 +674,13 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
673674 int ret ;
674675 int len ;
675676 int total ;
676- time_t now ;
677677 const char * header_color = NULL ;
678678 const char * header_title ;
679679 const char * bold_color = ANSI_BOLD ;
680680 const char * reset_color = ANSI_RESET ;
681681 struct tm result ;
682682 struct tm * current ;
683+ struct flb_time now ;
683684
684685 switch (type ) {
685686 case FLB_LOG_HELP :
@@ -718,16 +719,16 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
718719 }
719720 #endif // FLB_LOG_NO_CONTROL_CHARS
720721
721- now = time ( NULL );
722- current = localtime_r (& now , & result );
722+ flb_time_get ( & now );
723+ current = localtime_r (& now . tm . tv_sec , & result );
723724
724725 if (current == NULL ) {
725726 return -1 ;
726727 }
727728
728729 header_title = flb_log_message_type_str (type );
729730 len = snprintf (msg -> msg , sizeof (msg -> msg ) - 1 ,
730- "%s[%s%i/%02i/%02i %02i:%02i:%02i%s]%s [%s%5s%s] " ,
731+ "%s[%s%i/%02i/%02i %02i:%02i:%02i.%03ld %s]%s [%s%5s%s] " ,
731732 /* time */ /* type */
732733
733734 /* time variables */
@@ -738,6 +739,7 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
738739 current -> tm_hour ,
739740 current -> tm_min ,
740741 current -> tm_sec ,
742+ now .tm .tv_nsec ,
741743 bold_color , reset_color ,
742744
743745 /* type format */
0 commit comments