2525// should not be included if the "tracing" feature is disabled.
2626extern crate tracing_core;
2727
28- use tracing_core:: { field:: Field , span, Event , Subscriber } ;
28+ use tracing_core:: { Event , Subscriber , field:: Field , span} ;
2929use tracing_subscriber:: {
30+ Layer ,
3031 layer:: Context ,
3132 registry:: { LookupSpan , SpanRef } ,
32- Layer ,
3333} ;
3434
35- use serde_json:: { json , Value as JsonValue } ;
35+ use serde_json:: { Value as JsonValue , json } ;
3636use std:: {
3737 marker:: PhantomData ,
3838 path:: Path ,
3939 sync:: {
40- atomic:: { AtomicUsize , Ordering } ,
4140 Arc , Mutex ,
41+ atomic:: { AtomicUsize , Ordering } ,
4242 } ,
4343} ;
4444
@@ -308,10 +308,7 @@ fn create_default_writer() -> Box<dyn Write + Send> {
308308 Box :: new (
309309 std:: fs:: File :: create ( format ! (
310310 "./trace-{}.json" ,
311- std:: time:: SystemTime :: UNIX_EPOCH
312- . elapsed( )
313- . unwrap( )
314- . as_micros( )
311+ std:: time:: SystemTime :: UNIX_EPOCH . elapsed( ) . unwrap( ) . as_micros( )
315312 ) )
316313 . expect ( "Failed to create trace file." ) ,
317314 )
@@ -325,9 +322,7 @@ where
325322 let ( tx, rx) = mpsc:: channel ( ) ;
326323 OUT . with ( |val| val. replace ( Some ( tx. clone ( ) ) ) ) ;
327324
328- let out_writer = builder
329- . out_writer
330- . unwrap_or_else ( || create_default_writer ( ) ) ;
325+ let out_writer = builder. out_writer . unwrap_or_else ( || create_default_writer ( ) ) ;
331326
332327 let handle = std:: thread:: spawn ( move || {
333328 let mut write = BufWriter :: new ( out_writer) ;
@@ -437,10 +432,7 @@ where
437432 write. flush ( ) . unwrap ( ) ;
438433 } ) ;
439434
440- let guard = FlushGuard {
441- sender : tx. clone ( ) ,
442- handle : Cell :: new ( Some ( handle) ) ,
443- } ;
435+ let guard = FlushGuard { sender : tx. clone ( ) , handle : Cell :: new ( Some ( handle) ) } ;
444436 let layer = ChromeLayer {
445437 out : Arc :: new ( Mutex :: new ( tx) ) ,
446438 start : std:: time:: Instant :: now ( ) ,
@@ -488,19 +480,12 @@ where
488480 None
489481 }
490482 }
491- EventOrSpan :: Span ( s) => s
492- . extensions ( )
493- . get :: < ArgsWrapper > ( )
494- . map ( |e| & e. args )
495- . cloned ( ) ,
483+ EventOrSpan :: Span ( s) => s. extensions ( ) . get :: < ArgsWrapper > ( ) . map ( |e| & e. args ) . cloned ( ) ,
496484 } ;
497485 let name = name. unwrap_or_else ( || meta. name ( ) . into ( ) ) ;
498486 let target = target. unwrap_or_else ( || meta. target ( ) . into ( ) ) ;
499- let ( file, line) = if self . include_locations {
500- ( meta. file ( ) , meta. line ( ) )
501- } else {
502- ( None , None )
503- } ;
487+ let ( file, line) =
488+ if self . include_locations { ( meta. file ( ) , meta. line ( ) ) } else { ( None , None ) } ;
504489
505490 if new_thread {
506491 let name = match std:: thread:: current ( ) . name ( ) {
@@ -510,14 +495,7 @@ where
510495 self . send_message ( Message :: NewThread ( tid, name) ) ;
511496 }
512497
513- Callsite {
514- tid,
515- name,
516- target,
517- file,
518- line,
519- args,
520- }
498+ Callsite { tid, name, target, file, line, args }
521499 }
522500
523501 fn get_root_id ( & self , span : SpanRef < S > ) -> Option < i64 > {
@@ -534,7 +512,7 @@ where
534512 } else {
535513 None
536514 }
537- } ,
515+ }
538516 TraceStyle :: Async => Some (
539517 span. scope ( )
540518 . from_root ( )
@@ -543,7 +521,7 @@ where
543521 . unwrap_or ( span)
544522 . id ( )
545523 . into_u64 ( )
546- . cast_signed ( ) // the comment above explains the cast
524+ . cast_signed ( ) , // the comment above explains the cast
547525 ) ,
548526 }
549527 }
@@ -622,9 +600,7 @@ where
622600 if self . include_args {
623601 let mut args = Object :: new ( ) ;
624602 attrs. record ( & mut JsonVisitor { object : & mut args } ) ;
625- ctx. span ( id) . unwrap ( ) . extensions_mut ( ) . insert ( ArgsWrapper {
626- args : Arc :: new ( args) ,
627- } ) ;
603+ ctx. span ( id) . unwrap ( ) . extensions_mut ( ) . insert ( ArgsWrapper { args : Arc :: new ( args) } ) ;
628604 }
629605 if let TraceStyle :: Threaded = self . trace_style {
630606 return ;
@@ -650,8 +626,7 @@ struct JsonVisitor<'a> {
650626
651627impl < ' a > tracing_subscriber:: field:: Visit for JsonVisitor < ' a > {
652628 fn record_debug ( & mut self , field : & Field , value : & dyn std:: fmt:: Debug ) {
653- self . object
654- . insert ( field. name ( ) . to_owned ( ) , format ! ( "{value:?}" ) . into ( ) ) ;
629+ self . object . insert ( field. name ( ) . to_owned ( ) , format ! ( "{value:?}" ) . into ( ) ) ;
655630 }
656631}
657632
0 commit comments