diff --git a/util/src/logger.rs b/util/src/logger.rs index 1c2292cc4..c27682a2f 100644 --- a/util/src/logger.rs +++ b/util/src/logger.rs @@ -64,9 +64,8 @@ lazy_static! { terminal_drain = slog_async::Async::new(Discard{}).build().fuse(); } - //File drain - let mut file_drain_final = slog_async::Async::new(Discard{}).build().fuse(); if config.log_to_file && was_init { + //File drain let file = OpenOptions::new() .create(true) .write(true) @@ -78,14 +77,14 @@ lazy_static! { let file_decorator = slog_term::PlainDecorator::new(file); let file_drain = slog_term::FullFormat::new(file_decorator).build().fuse(); let file_drain = LevelFilter::new(file_drain, slog_level_file).fuse(); - file_drain_final = slog_async::Async::new(file_drain).build().fuse(); + let file_drain_final = slog_async::Async::new(file_drain).build().fuse(); + + let composite_drain = Duplicate::new(terminal_drain, file_drain_final).fuse(); + + Logger::root(composite_drain, o!()) + } else { + Logger::root(terminal_drain, o!()) } - - //Compose file and terminal drains - let composite_drain = Duplicate::new(terminal_drain, file_drain_final).fuse(); - - let log = Logger::root(composite_drain, o!()); - log }; }