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.
pull/243/head
Thomas Eizinger 3 years ago
parent a82e82edd5
commit f4827e3fa4
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

17
Cargo.lock generated

@ -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",

@ -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"

@ -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)?;

Loading…
Cancel
Save