@@ -202,8 +202,14 @@ pub trait AsWorker : Scheduler {
202
202
fn peek_identifier ( & self ) -> usize ;
203
203
/// Provides access to named logging streams.
204
204
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
+ }
205
211
/// 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) }
207
213
}
208
214
209
215
/// A `Worker` is the entry point to a timely dataflow computation. It wraps a `Allocate`,
@@ -579,8 +585,7 @@ impl<A: Allocate> Worker<A> {
579
585
T : Refines < ( ) > ,
580
586
F : FnOnce ( & mut Child < Self , T > ) ->R ,
581
587
{
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) )
584
589
}
585
590
586
591
/// Construct a new dataflow with a (purely cosmetic) name.
@@ -603,8 +608,7 @@ impl<A: Allocate> Worker<A> {
603
608
T : Refines < ( ) > ,
604
609
F : FnOnce ( & mut Child < Self , T > ) ->R ,
605
610
{
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) )
608
612
}
609
613
610
614
/// Construct a new dataflow with specific configurations.
@@ -643,8 +647,8 @@ impl<A: Allocate> Worker<A> {
643
647
let identifier = self . new_identifier ( ) ;
644
648
645
649
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) ) ;
648
652
let subscope = SubgraphBuilder :: new_from ( addr, identifier, logging. clone ( ) , summary_logging, name) ;
649
653
let subscope = RefCell :: new ( subscope) ;
650
654
0 commit comments