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