11use crate :: logger:: fast_hash:: fast_str_hash;
22use crate :: { CircularBuffer , LevelConfig , TuiLoggerFile } ;
3- use chrono:: { DateTime , Local } ;
43use env_filter:: Filter ;
4+ use jiff:: Zoned ;
55use log:: { Level , LevelFilter , Log , Metadata , Record } ;
66use parking_lot:: Mutex ;
77use std:: collections:: HashMap ;
@@ -41,7 +41,7 @@ impl StringOrStatic {
4141}
4242
4343pub struct ExtLogRecord {
44- pub timestamp : DateTime < Local > ,
44+ pub timestamp : Zoned ,
4545 pub level : Level ,
4646 target : String ,
4747 file : Option < StringOrStatic > ,
@@ -84,7 +84,7 @@ impl ExtLogRecord {
8484 . map ( |s| StringOrStatic :: IsString ( s. to_string ( ) ) )
8585 } ) ;
8686 ExtLogRecord {
87- timestamp : chrono :: Local :: now ( ) ,
87+ timestamp : Zoned :: now ( ) ,
8888 level : record. level ( ) ,
8989 target : record. target ( ) . to_string ( ) ,
9090 file,
@@ -93,7 +93,7 @@ impl ExtLogRecord {
9393 msg : format ! ( "{}" , record. args( ) ) ,
9494 }
9595 }
96- fn overrun ( timestamp : DateTime < Local > , total : usize , elements : usize ) -> Self {
96+ fn overrun ( timestamp : Zoned , total : usize , elements : usize ) -> Self {
9797 ExtLogRecord {
9898 timestamp,
9999 level : Level :: Warn ,
@@ -148,8 +148,11 @@ impl TuiLogger {
148148 }
149149 if total > elements {
150150 // Too many events received, so some have been lost
151- let new_log_entry =
152- ExtLogRecord :: overrun ( reversed[ reversed. len ( ) - 1 ] . timestamp , total, elements) ;
151+ let new_log_entry = ExtLogRecord :: overrun (
152+ reversed[ reversed. len ( ) - 1 ] . timestamp . clone ( ) ,
153+ total,
154+ elements,
155+ ) ;
153156 reversed. push ( new_log_entry) ;
154157 }
155158 while let Some ( log_entry) = reversed. pop ( ) {
@@ -198,7 +201,7 @@ impl TuiLogger {
198201 log:: Level :: Trace => ( "TRACE" , "T" , true ) ,
199202 } ;
200203 if let Some ( fmt) = file_options. timestamp_fmt . as_ref ( ) {
201- output. push_str ( & format ! ( "{}" , log_entry. timestamp. format ( fmt) ) ) ;
204+ output. push_str ( & log_entry. timestamp . strftime ( fmt) . to_string ( ) ) ;
202205 output. push ( file_options. format_separator ) ;
203206 }
204207 match file_options. format_output_level {
@@ -294,8 +297,10 @@ impl TuiLogger {
294297 let log_entry = ExtLogRecord :: from ( record) ;
295298 let mut events_lock = self . hot_log . lock ( ) ;
296299 events_lock. events . push ( log_entry) ;
297- let need_signal =
298- events_lock. events . total_elements ( ) . is_multiple_of ( events_lock. events . capacity ( ) / 2 ) ;
300+ let need_signal = events_lock
301+ . events
302+ . total_elements ( )
303+ . is_multiple_of ( events_lock. events . capacity ( ) / 2 ) ;
299304 if need_signal {
300305 if let Some ( jh) = events_lock. mover_thread . as_ref ( ) {
301306 thread:: Thread :: unpark ( jh. thread ( ) ) ;
0 commit comments