@@ -114,7 +114,7 @@ impl SimpleLogger {
114
114
#[ cfg( feature = "timestamps" ) ]
115
115
timestamps : Timestamps :: Utc ,
116
116
#[ cfg( feature = "timestamps" ) ]
117
- timeformat : TIMESTAMP_FORMAT_OFFSET ,
117
+ timeformat : time :: macros :: format_description! ( "" ) ,
118
118
119
119
#[ cfg( feature = "colored" ) ]
120
120
colors : true ,
@@ -345,6 +345,16 @@ impl SimpleLogger {
345
345
#[ cfg( all( windows, feature = "colored" ) ) ]
346
346
set_up_color_terminal ( ) ;
347
347
348
+ // Set default timestamp format
349
+ if self . timeformat . len ( ) <= 0 {
350
+ self . timeformat = match self . timestamps {
351
+ Timestamps :: Local => TIMESTAMP_FORMAT_OFFSET ,
352
+ Timestamps :: Utc => TIMESTAMP_FORMAT_UTC ,
353
+ Timestamps :: UtcOffset ( _) => TIMESTAMP_FORMAT_OFFSET ,
354
+ _ => self . timeformat ,
355
+ } ;
356
+ }
357
+
348
358
/* Sort all module levels from most specific to least specific. The length of the module
349
359
* name is used instead of its actual depth to avoid module name parsing.
350
360
*/
@@ -453,7 +463,7 @@ impl Log for SimpleLogger {
453
463
. format( & self . timeformat)
454
464
. unwrap( )
455
465
) ,
456
- Timestamps :: Utc => format ! ( "{} " , OffsetDateTime :: now_utc( ) . format( & TIMESTAMP_FORMAT_UTC ) . unwrap( ) ) ,
466
+ Timestamps :: Utc => format ! ( "{} " , OffsetDateTime :: now_utc( ) . format( & self . timeformat ) . unwrap( ) ) ,
457
467
Timestamps :: UtcOffset ( offset) => format ! (
458
468
"{} " ,
459
469
OffsetDateTime :: now_utc( )
0 commit comments