@@ -27,9 +27,9 @@ use tauri::{
2727 Manager , Runtime ,
2828} ;
2929use tauri:: { AppHandle , Emitter } ;
30+ use time:: { macros:: format_description, OffsetDateTime } ;
3031
3132pub use fern;
32- use time:: OffsetDateTime ;
3333
3434pub const WEBVIEW_TARGET : & str = "webview" ;
3535
@@ -277,9 +277,7 @@ pub struct Builder {
277277impl Default for Builder {
278278 fn default ( ) -> Self {
279279 #[ cfg( desktop) ]
280- let format =
281- time:: format_description:: parse ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" )
282- . unwrap ( ) ;
280+ let format = format_description ! ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" ) ;
283281 let dispatch = fern:: Dispatch :: new ( ) . format ( move |out, message, record| {
284282 out. finish (
285283 #[ cfg( mobile) ]
@@ -318,9 +316,7 @@ impl Builder {
318316 pub fn timezone_strategy ( mut self , timezone_strategy : TimezoneStrategy ) -> Self {
319317 self . timezone_strategy = timezone_strategy. clone ( ) ;
320318
321- let format =
322- time:: format_description:: parse ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" )
323- . unwrap ( ) ;
319+ let format = format_description ! ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" ) ;
324320 self . dispatch = self . dispatch . format ( move |out, message, record| {
325321 out. finish ( format_args ! (
326322 "{}[{}][{}] {}" ,
@@ -417,9 +413,7 @@ impl Builder {
417413
418414 #[ cfg( feature = "colored" ) ]
419415 pub fn with_colors ( self , colors : fern:: colors:: ColoredLevelConfig ) -> Self {
420- let format =
421- time:: format_description:: parse ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" )
422- . unwrap ( ) ;
416+ let format = format_description ! ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" ) ;
423417
424418 let timezone_strategy = self . timezone_strategy . clone ( ) ;
425419 self . format ( move |out, message, record| {
@@ -601,11 +595,9 @@ fn get_log_file_path(
601595 let to = dir. as_ref ( ) . join ( format ! (
602596 "{}_{}.log" ,
603597 file_name,
604- timezone_strategy
605- . get_now( )
606- . format( & time:: format_description:: parse(
607- "[year]-[month]-[day]_[hour]-[minute]-[second]"
608- ) ?) ?,
598+ timezone_strategy. get_now( ) . format( & format_description!(
599+ "[year]-[month]-[day]_[hour]-[minute]-[second]"
600+ ) ) ?,
609601 ) ) ;
610602 if to. is_file ( ) {
611603 // designated rotated log file name already exists
0 commit comments