@@ -27,9 +27,9 @@ use tauri::{
27
27
Manager , Runtime ,
28
28
} ;
29
29
use tauri:: { AppHandle , Emitter } ;
30
+ use time:: { macros:: format_description, OffsetDateTime } ;
30
31
31
32
pub use fern;
32
- use time:: OffsetDateTime ;
33
33
34
34
pub const WEBVIEW_TARGET : & str = "webview" ;
35
35
@@ -277,9 +277,7 @@ pub struct Builder {
277
277
impl Default for Builder {
278
278
fn default ( ) -> Self {
279
279
#[ 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]]" ) ;
283
281
let dispatch = fern:: Dispatch :: new ( ) . format ( move |out, message, record| {
284
282
out. finish (
285
283
#[ cfg( mobile) ]
@@ -318,9 +316,7 @@ impl Builder {
318
316
pub fn timezone_strategy ( mut self , timezone_strategy : TimezoneStrategy ) -> Self {
319
317
self . timezone_strategy = timezone_strategy. clone ( ) ;
320
318
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]]" ) ;
324
320
self . dispatch = self . dispatch . format ( move |out, message, record| {
325
321
out. finish ( format_args ! (
326
322
"{}[{}][{}] {}" ,
@@ -416,9 +412,7 @@ impl Builder {
416
412
417
413
#[ cfg( feature = "colored" ) ]
418
414
pub fn with_colors ( self , colors : fern:: colors:: ColoredLevelConfig ) -> Self {
419
- let format =
420
- time:: format_description:: parse ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" )
421
- . unwrap ( ) ;
415
+ let format = format_description ! ( "[[[year]-[month]-[day]][[[hour]:[minute]:[second]]" ) ;
422
416
423
417
let timezone_strategy = self . timezone_strategy . clone ( ) ;
424
418
self . format ( move |out, message, record| {
@@ -600,11 +594,9 @@ fn get_log_file_path(
600
594
let to = dir. as_ref ( ) . join ( format ! (
601
595
"{}_{}.log" ,
602
596
file_name,
603
- timezone_strategy
604
- . get_now( )
605
- . format( & time:: format_description:: parse(
606
- "[year]-[month]-[day]_[hour]-[minute]-[second]"
607
- ) ?) ?,
597
+ timezone_strategy. get_now( ) . format( & format_description!(
598
+ "[year]-[month]-[day]_[hour]-[minute]-[second]"
599
+ ) ) ?,
608
600
) ) ;
609
601
if to. is_file ( ) {
610
602
// designated rotated log file name already exists
0 commit comments