diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-09-05 10:17:37 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-09-05 10:17:37 +0100 |
commit | a28baee83894585e632706e61f27ad65b0115f82 (patch) | |
tree | 72c143db71afb01b48d441070594dfdc93725d7d /src/bin/subplot.rs | |
parent | 6cb160b8403ab314e30d66ebf96eff42a1fde396 (diff) | |
download | subplot-a28baee83894585e632706e61f27ad65b0115f82.tar.gz |
tracing: Un-DRY the code a bit to cope with a guard
Unfortunately there was a problem where the file writer guard
got dropped and so the subscriber (correctly) silently swallowed
the tracing instead of writing it out. This was caused by me
trying to DRY the code a bit. Undo some of that until we can come
up with a more elegant solution.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/bin/subplot.rs')
-rw-r--r-- | src/bin/subplot.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs index f4eb678..d4685da 100644 --- a/src/bin/subplot.rs +++ b/src/bin/subplot.rs @@ -470,7 +470,7 @@ fn main() { process::exit(1); } }; - let subscriber = match std::env::var("SUBPLOT_LOG_FILE").ok().as_deref() { + match std::env::var("SUBPLOT_LOG_FILE").ok().as_deref() { None | Some("") | Some("-") => { let subscriber = tracing_subscriber::fmt().with_env_filter(filter); let subscriber: Box<dyn Subscriber + Send + Sync + 'static> = match format { @@ -478,7 +478,7 @@ fn main() { LogFormat::Pretty => Box::new(subscriber.pretty().finish()), LogFormat::Json => Box::new(subscriber.json().with_ansi(false).finish()), }; - subscriber + tracing::subscriber::with_default(subscriber, real_main); } Some(fname) => { let curdir = std::path::Component::CurDir; @@ -498,8 +498,7 @@ fn main() { LogFormat::Pretty => Box::new(subscriber.pretty().finish()), LogFormat::Json => Box::new(subscriber.json().finish()), }; - subscriber + tracing::subscriber::with_default(subscriber, real_main); } - }; - tracing::subscriber::with_default(subscriber, real_main); + } } |