@@ -11,14 +11,14 @@ use crate::RuntimeRequestSink;
1111use futures:: channel:: mpsc;
1212use futures:: prelude:: * ;
1313use futures:: stream:: FuturesUnordered ;
14- use log:: debug;
15- use log:: error;
16- use log:: info;
1714use std:: collections:: HashMap ;
1815use std:: panic;
1916use std:: time:: Duration ;
2017use tokio:: task:: JoinError ;
2118use tokio:: task:: JoinHandle ;
19+ use tracing:: debug;
20+ use tracing:: error;
21+ use tracing:: info;
2222
2323/// Actions sent by actors to the runtime
2424#[ derive( Debug ) ]
@@ -95,7 +95,7 @@ impl Runtime {
9595 /// and all the running tasks have reach completion (successfully or not).
9696 pub async fn run_to_completion ( self ) -> Result < ( ) , RuntimeError > {
9797 if let Err ( err) = Runtime :: wait_for_completion ( self . bg_task ) . await {
98- error ! ( "Aborted due to {err}" ) ;
98+ error ! ( target : "Actors" , "Aborted due to {err}" ) ;
9999 std:: process:: exit ( 1 )
100100 }
101101
@@ -138,7 +138,7 @@ impl RuntimeHandle {
138138
139139 /// Send an action to the runtime
140140 async fn send ( & mut self , action : RuntimeAction ) -> Result < ( ) , ChannelError > {
141- debug ! ( target: "Runtime " , "schedule {:?}" , action) ;
141+ debug ! ( target: "Actors " , "schedule {:?}" , action) ;
142142 self . actions_sender . send ( action) . await ?;
143143 Ok ( ( ) )
144144 }
@@ -175,7 +175,7 @@ impl RuntimeActor {
175175 }
176176
177177 async fn run ( mut self ) -> Result < ( ) , RuntimeError > {
178- info ! ( target: "Runtime " , "Started" ) ;
178+ info ! ( target: "Actors " , "Started" ) ;
179179 let mut aborting_error = None ;
180180 let mut actors_count: usize = 0 ;
181181 loop {
@@ -186,7 +186,7 @@ impl RuntimeActor {
186186 match action {
187187 RuntimeAction :: Spawn ( actor) => {
188188 let running_name = format!( "{}-{}" , actor. name( ) , actors_count) ;
189- info!( target: "Runtime " , "Running {running_name}" ) ;
189+ info!( target: "Actors " , "Running {running_name}" ) ;
190190 self . send_event( RuntimeEvent :: Started {
191191 task: running_name. clone( ) ,
192192 } )
@@ -196,22 +196,22 @@ impl RuntimeActor {
196196 actors_count += 1 ;
197197 }
198198 RuntimeAction :: Shutdown => {
199- info!( target: "Runtime " , "Shutting down" ) ;
199+ info!( target: "Actors " , "Shutting down" ) ;
200200 shutdown_actors( & mut self . running_actors) . await ;
201201 break ;
202202 }
203203 }
204204 }
205205 None => {
206- info!( target: "Runtime " , "Runtime actions channel closed, runtime stopping" ) ;
206+ info!( target: "Actors " , "Runtime actions channel closed, runtime stopping" ) ;
207207 shutdown_actors( & mut self . running_actors) . await ;
208208 break ;
209209 }
210210 }
211211 } ,
212212 Some ( finished_actor) = self . futures. next( ) => {
213213 if let Err ( error) = self . handle_actor_finishing( finished_actor) . await {
214- info!( target: "Runtime " , "Shutting down on error: {error}" ) ;
214+ info!( target: "Actors " , "Shutting down on error: {error}" ) ;
215215 aborting_error = Some ( error) ;
216216 shutdown_actors( & mut self . running_actors) . await ;
217217 break
@@ -222,12 +222,12 @@ impl RuntimeActor {
222222
223223 tokio:: select! {
224224 _ = tokio:: time:: sleep( self . cleanup_duration) => {
225- error!( target: "Runtime " , "Timeout waiting for all actors to shutdown" ) ;
225+ error!( target: "Actors " , "Timeout waiting for all actors to shutdown" ) ;
226226 for still_running in self . running_actors. keys( ) {
227- error!( target: "Runtime " , "Failed to shutdown: {still_running}" )
227+ error!( target: "Actors " , "Failed to shutdown: {still_running}" )
228228 }
229229 }
230- _ = self . wait_for_actors_to_finish( ) => info!( target: "Runtime " , "All actors have finished" )
230+ _ = self . wait_for_actors_to_finish( ) => info!( target: "Actors " , "All actors have finished" )
231231 }
232232
233233 match aborting_error {
@@ -248,18 +248,18 @@ impl RuntimeActor {
248248 ) -> Result < ( ) , RuntimeError > {
249249 match finished_actor {
250250 Err ( e) => {
251- error ! ( target: "Runtime " , "Failed to execute actor: {e}" ) ;
251+ error ! ( target: "Actors " , "Failed to execute actor: {e}" ) ;
252252 Err ( RuntimeError :: JoinError ( e) )
253253 }
254254 Ok ( Ok ( actor) ) => {
255255 self . running_actors . remove ( & actor) ;
256- info ! ( target: "Runtime " , "Actor has finished: {actor}" ) ;
256+ info ! ( target: "Actors " , "Actor has finished: {actor}" ) ;
257257 self . send_event ( RuntimeEvent :: Stopped { task : actor } ) . await ;
258258 Ok ( ( ) )
259259 }
260260 Ok ( Err ( ( actor, error) ) ) => {
261261 self . running_actors . remove ( & actor) ;
262- error ! ( target: "Runtime " , "Actor {actor} has finished unsuccessfully: {error:?}" ) ;
262+ error ! ( target: "Actors " , "Actor {actor} has finished unsuccessfully: {error:?}" ) ;
263263 self . send_event ( RuntimeEvent :: Aborted {
264264 task : actor. clone ( ) ,
265265 error : format ! ( "{error}" ) ,
@@ -273,7 +273,7 @@ impl RuntimeActor {
273273 async fn send_event ( & mut self , event : RuntimeEvent ) {
274274 if let Some ( events) = & mut self . events {
275275 if let Err ( e) = events. send ( event) . await {
276- error ! ( target: "Runtime " , "Failed to send RuntimeEvent: {e}" ) ;
276+ error ! ( target: "Actors " , "Failed to send RuntimeEvent: {e}" ) ;
277277 }
278278 }
279279 }
@@ -286,10 +286,10 @@ where
286286 for ( running_as, sender) in a {
287287 match sender. send ( RuntimeRequest :: Shutdown ) . await {
288288 Ok ( ( ) ) => {
289- debug ! ( target: "Runtime " , "Successfully sent shutdown request to {running_as}" )
289+ debug ! ( target: "Actors " , "Successfully sent shutdown request to {running_as}" )
290290 }
291291 Err ( e) => {
292- error ! ( target: "Runtime " , "Failed to send shutdown request to {running_as}: {e:?}" )
292+ error ! ( target: "Actors " , "Failed to send shutdown request to {running_as}: {e:?}" )
293293 }
294294 }
295295 }
0 commit comments