From fa0d5b68fb970d80f0a1eea92fa9005f7e7774b1 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Sat, 30 Dec 2017 00:07:29 -0500 Subject: [PATCH] sets file_logger to return a noop logger if cfg(test) --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 98a7c34..1bf90b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,6 +44,7 @@ pub fn nanos(t: DateTime) -> u64 { (t.timestamp() as u64) * 1_000_000_000_u64 + (t.timestamp_subsec_nanos() as u64) } +#[cfg(not(test))] pub fn file_logger(path: &str, level: Severity) -> slog::Logger { let mut builder = FileLoggerBuilder::new(path); builder.level(level); @@ -51,6 +52,13 @@ pub fn file_logger(path: &str, level: Severity) -> slog::Logger { builder.build().unwrap() } + +#[cfg(test)] +pub fn file_logger(path: &str, level: Severity) -> slog::Logger { + use slog::*; + Logger::root(Discard, o!()) +} + pub fn dt_nanos(t: DateTime) -> i64 { (t.timestamp() as i64) * 1_000_000_000_i64 + (t.timestamp_subsec_nanos() as i64) }