From f4827e3fa48fafd0335bc71fcdf517ee2db07c3d Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 1 Mar 2021 12:04:39 +1100 Subject: [PATCH] Improve time formatting of log output Previously, the time was formatted as ISO8601 timestamps which is barely readable by humans. Activating the `chrono` feature allows us to format with a different format string. The output now looks like this: 2021-03-01 11:59:52 DEBUG Database and seed will be stored in /home/thomas/.local/share/xmr-btc-swap 2021-03-01 11:59:52 DEBUG Starting monero-wallet-rpc on port 40673 2021-03-01 11:59:59 DEBUG Still got 0.00009235 BTC left in wallet, swapping ... 2021-03-01 11:59:59 DEBUG Dialing alice at 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi 2021-03-01 11:59:59 DEBUG Requesting quote for 0.00008795 BTC There is a double space after the time which is already fixed in tracing-subscriber but not yet released. See https://github.com/tokio-rs/tracing/issues/1271. --- Cargo.lock | 17 +++++++++++++++-- swap/Cargo.toml | 2 +- swap/src/bin/swap_cli.rs | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc6a00c4..5453e121 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -566,6 +566,18 @@ dependencies = [ "zeroize 1.2.0", ] +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "winapi 0.3.9", +] + [[package]] name = "clap" version = "2.33.3" @@ -3950,11 +3962,12 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" +checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96" dependencies = [ "ansi_term 0.12.1", + "chrono", "lazy_static", "matchers", "regex", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 8a615b3a..165e5bae 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -58,7 +58,7 @@ toml = "0.5" tracing = { version = "0.1", features = ["attributes"] } tracing-futures = { version = "0.2", features = ["std-future", "futures-03"] } tracing-log = "0.1" -tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt", "ansi", "env-filter"] } +tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt", "ansi", "env-filter", "chrono"] } url = { version = "2.1", features = ["serde"] } uuid = { version = "0.8", features = ["serde", "v4"] } void = "1" diff --git a/swap/src/bin/swap_cli.rs b/swap/src/bin/swap_cli.rs index 4304de94..853b8432 100644 --- a/swap/src/bin/swap_cli.rs +++ b/swap/src/bin/swap_cli.rs @@ -52,6 +52,9 @@ async fn main() -> Result<()> { .with_writer(std::io::stderr) .with_ansi(is_terminal) .with_target(false) + .with_timer(tracing_subscriber::fmt::time::ChronoLocal::with_format( + "%F %T".to_owned(), + )) .finish(); tracing::subscriber::set_global_default(subscriber)?;