Skip to content

Commit

Permalink
Improve logs when spawning connection and channel workers
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Jan 20, 2022
1 parent 42b917f commit 0f301b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions relayer/src/util/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::time::Duration;
use crossbeam_channel::{bounded, Sender};
use std::sync::{Arc, RwLock};
use std::thread;
use tracing::{error, info, warn};
use tracing::{debug, error, warn};

use crate::util::lock::LockExt;

Expand Down Expand Up @@ -90,7 +90,7 @@ pub fn spawn_background_task<E: Display>(
interval_pause: Option<Duration>,
mut step_runner: impl FnMut() -> Result<Next, TaskError<E>> + Send + Sync + 'static,
) -> TaskHandle {
info!(parent: &span, "spawning");
debug!(parent: &span, "spawning task");

let stopped = Arc::new(RwLock::new(false));
let write_stopped = stopped.clone();
Expand All @@ -107,14 +107,14 @@ pub fn spawn_background_task<E: Display>(
_ => match step_runner() {
Ok(Next::Continue) => {}
Ok(Next::Abort) => {
info!("aborting");
debug!("aborting task");
break;
}
Err(TaskError::Ignore(e)) => {
warn!("encountered ignorable error: {}", e);
warn!("task encountered ignorable error: {}", e);
}
Err(TaskError::Fatal(e)) => {
error!("aborting after encountering fatal error: {}", e);
error!("task aborting after encountering fatal error: {}", e);
break;
}
},
Expand All @@ -125,7 +125,8 @@ pub fn spawn_background_task<E: Display>(
}

*write_stopped.acquire_write() = true;
info!("terminated");

debug!("task terminated");
});

TaskHandle {
Expand Down
2 changes: 1 addition & 1 deletion relayer/src/worker/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn spawn_channel_worker<ChainA: ChainHandle, ChainB: ChainHandle>(
cmd_rx: Receiver<WorkerCmd>,
) -> TaskHandle {
spawn_background_task(
error_span!("channel", channel = %channel.short_name()),
error_span!("worker.channel", object = %channel.short_name()),
Some(Duration::from_millis(200)),
move || {
if let Ok(cmd) = cmd_rx.try_recv() {
Expand Down

0 comments on commit 0f301b5

Please sign in to comment.