@@ -202,8 +202,14 @@ pub trait AsWorker : Scheduler {
202202 fn peek_identifier ( & self ) -> usize ;
203203 /// Provides access to named logging streams.
204204 fn log_register ( & self ) -> Option < :: std:: cell:: RefMut < crate :: logging_core:: Registry > > ;
205+ /// Acquires a logger by name, if the log register exists and the name is registered.
206+ ///
207+ /// For a more precise understanding of why a result is `None` one can use the direct functions.
208+ fn logger_for < CB : timely_container:: ContainerBuilder > ( & self , name : & str ) -> Option < timely_logging:: Logger < CB > > {
209+ self . log_register ( ) . and_then ( |l| l. get ( name) )
210+ }
205211 /// Provides access to the timely logging stream.
206- fn logging ( & self ) -> Option < crate :: logging:: TimelyLogger > { self . log_register ( ) . and_then ( |l| l . get ( "timely" ) . map ( Into :: into) ) }
212+ fn logging ( & self ) -> Option < crate :: logging:: TimelyLogger > { self . logger_for ( "timely" ) . map ( Into :: into) }
207213}
208214
209215/// A `Worker` is the entry point to a timely dataflow computation. It wraps a `Allocate`,
@@ -579,8 +585,7 @@ impl<A: Allocate> Worker<A> {
579585 T : Refines < ( ) > ,
580586 F : FnOnce ( & mut Child < Self , T > ) ->R ,
581587 {
582- let logging = self . logging . as_ref ( ) . map ( |l| l. borrow_mut ( ) ) . and_then ( |l| l. get ( "timely" ) . map ( Into :: into) ) ;
583- self . dataflow_core ( "Dataflow" , logging, Box :: new ( ( ) ) , |_, child| func ( child) )
588+ self . dataflow_core ( "Dataflow" , self . logging ( ) , Box :: new ( ( ) ) , |_, child| func ( child) )
584589 }
585590
586591 /// Construct a new dataflow with a (purely cosmetic) name.
@@ -603,8 +608,7 @@ impl<A: Allocate> Worker<A> {
603608 T : Refines < ( ) > ,
604609 F : FnOnce ( & mut Child < Self , T > ) ->R ,
605610 {
606- let logging = self . logging . as_ref ( ) . map ( |l| l. borrow_mut ( ) ) . and_then ( |l| l. get ( "timely" ) . map ( Into :: into) ) ;
607- self . dataflow_core ( name, logging, Box :: new ( ( ) ) , |_, child| func ( child) )
611+ self . dataflow_core ( name, self . logging ( ) , Box :: new ( ( ) ) , |_, child| func ( child) )
608612 }
609613
610614 /// Construct a new dataflow with specific configurations.
@@ -643,8 +647,8 @@ impl<A: Allocate> Worker<A> {
643647 let identifier = self . new_identifier ( ) ;
644648
645649 let type_name = std:: any:: type_name :: < T > ( ) ;
646- let progress_logging = self . logging . as_ref ( ) . map ( |l| l . borrow_mut ( ) ) . and_then ( |l| l . get ( & format ! ( "timely/progress/{}" , type_name) ) . map ( Into :: into ) ) ;
647- let summary_logging = self . logging . as_ref ( ) . map ( |l| l . borrow_mut ( ) ) . and_then ( |l| l . get ( & format ! ( "timely/summary/{}" , type_name) ) . map ( Into :: into ) ) ;
650+ let progress_logging = self . logger_for ( & format ! ( "timely/progress/{}" , type_name) ) ;
651+ let summary_logging = self . logger_for ( & format ! ( "timely/summary/{}" , type_name) ) ;
648652 let subscope = SubgraphBuilder :: new_from ( addr, identifier, logging. clone ( ) , summary_logging, name) ;
649653 let subscope = RefCell :: new ( subscope) ;
650654
0 commit comments