Skip to content

Commit

Permalink
Improve time formatting of log output
Browse files Browse the repository at this point in the history
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 tokio-rs/tracing#1271.
  • Loading branch information
abraham-nixon committed Mar 1, 2021
1 parent 08ca6f8 commit 5ed08b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions swap/src/bin/swap_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 5ed08b1

Please sign in to comment.