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.
This commit is contained in:
Thomas Eizinger 2021-03-01 12:04:39 +11:00
parent a82e82edd5
commit f4827e3fa4
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
3 changed files with 19 additions and 3 deletions

View file

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