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 */
@@ -800,11 +802,8 @@ void flb_log_print(int type, const char *file, int line, const char *fmt, ...)
800
802
int ret ;
801
803
struct log_message msg = {0 };
802
804
va_list args ;
803
- const char * msg_type_str ;
804
- uint64_t ts ;
805
805
806
806
struct flb_worker * w ;
807
- struct flb_config * config ;
808
807
809
808
va_start (args , fmt );
810
809
ret = flb_log_construct (& msg , & len , type , file , line , fmt , & args );
@@ -816,25 +815,6 @@ void flb_log_print(int type, const char *file, int line, const char *fmt, ...)
816
815
817
816
w = flb_worker_get ();
818
817
if (w ) {
819
- config = w -> config ;
820
- if (config != NULL && config -> log != NULL ) {
821
- msg_type_str = flb_log_message_type_str (type );
822
- if (msg_type_str == NULL ) {
823
- msg_type_str = "unknown" ;
824
- }
825
-
826
- ts = cfl_time_now ();
827
- ret = cmt_counter_inc (config -> log -> metrics -> logs_total_counter ,
828
- ts ,
829
- 1 , (char * []) {msg_type_str });
830
- if (ret == -1 ) {
831
- /* Not using flb_log_debug to avoid recursing into this same function. */
832
- fprintf (stderr ,
833
- "[log] failed to increment log total counter for message type '%s' (error=%d)\n" ,
834
- msg_type_str , ret );
835
- }
836
- }
837
-
838
818
n = flb_pipe_write_all (w -> log [1 ], & msg , sizeof (msg ));
839
819
840
820
if (n == -1 ) {
@@ -894,7 +874,6 @@ int flb_log_destroy(struct flb_log *log, struct flb_config *config)
894
874
}
895
875
flb_log_worker_destroy (log -> worker );
896
876
flb_free (log -> worker );
897
- flb_log_metrics_destroy (log -> metrics );
898
877
flb_free (log );
899
878
900
879
return 0 ;
0 commit comments