32
32
#include <fluent-bit/flb_config.h>
33
33
#include <fluent-bit/flb_worker.h>
34
34
#include <fluent-bit/flb_mem.h>
35
+ #include <fluent-bit/flb_time.h>
35
36
#include <cmetrics/cmetrics.h>
36
37
#include <cmetrics/cmt_counter.h>
37
38
@@ -673,13 +674,13 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
673
674
int ret ;
674
675
int len ;
675
676
int total ;
676
- time_t now ;
677
677
const char * header_color = NULL ;
678
678
const char * header_title ;
679
679
const char * bold_color = ANSI_BOLD ;
680
680
const char * reset_color = ANSI_RESET ;
681
681
struct tm result ;
682
682
struct tm * current ;
683
+ struct flb_time now ;
683
684
684
685
switch (type ) {
685
686
case FLB_LOG_HELP :
@@ -718,16 +719,16 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
718
719
}
719
720
#endif // FLB_LOG_NO_CONTROL_CHARS
720
721
721
- now = time ( NULL );
722
- current = localtime_r (& now , & result );
722
+ flb_time_get ( & now );
723
+ current = localtime_r (& now . tm . tv_sec , & result );
723
724
724
725
if (current == NULL ) {
725
726
return -1 ;
726
727
}
727
728
728
729
header_title = flb_log_message_type_str (type );
729
730
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] " ,
731
732
/* time */ /* type */
732
733
733
734
/* time variables */
@@ -738,6 +739,7 @@ int flb_log_construct(struct log_message *msg, int *ret_len,
738
739
current -> tm_hour ,
739
740
current -> tm_min ,
740
741
current -> tm_sec ,
742
+ now .tm .tv_nsec ,
741
743
bold_color , reset_color ,
742
744
743
745
/* type format */
0 commit comments