Skip to content

Commit 592b7e6

Browse files
committed
Add more logging
1 parent ea408f7 commit 592b7e6

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlxmq"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
authors = ["Diggory Blake <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"
@@ -23,7 +23,7 @@ uuid = { version = "0.8.2", features = ["v4"] }
2323
log = "0.4.14"
2424
serde_json = "1.0.64"
2525
serde = "1.0.124"
26-
sqlxmq_macros = { version = "0.3.3", path = "sqlxmq_macros" }
26+
sqlxmq_macros = { version = "0.3.4", path = "sqlxmq_macros" }
2727
anymap2 = "0.13.0"
2828

2929
[features]

sqlxmq_macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlxmq_macros"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
authors = ["Diggory Blake <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"

src/registry.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::error::Error;
44
use std::fmt::Display;
55
use std::future::Future;
66
use std::sync::Arc;
7+
use std::time::Instant;
78

89
use anymap2::any::CloneAnySendSync;
910
use anymap2::Map;
@@ -83,7 +84,7 @@ impl JobRegistry {
8384

8485
/// The default error handler implementation, which simply logs the error.
8586
pub fn default_error_handler(name: &str, error: Box<dyn Error + Send + 'static>) {
86-
log::error!("Job {} failed: {}", name, error);
87+
log::error!("Job `{}` failed: {}", name, error);
8788
}
8889

8990
#[doc(hidden)]
@@ -94,8 +95,16 @@ impl JobRegistry {
9495
) {
9596
let error_handler = self.error_handler.clone();
9697
tokio::spawn(async move {
98+
let start_time = Instant::now();
99+
log::info!("Job `{}` started.", name);
97100
if let Err(e) = f.await {
98101
error_handler(name, e.into());
102+
} else {
103+
log::info!(
104+
"Job `{}` completed in {}s.",
105+
name,
106+
start_time.elapsed().as_secs_f64()
107+
);
99108
}
100109
});
101110
}

0 commit comments

Comments
 (0)