From 5b716e411bc76b0d1d5e4f702d4aff351c9b720d Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Tue, 2 Jan 2018 08:48:39 -0500 Subject: [PATCH] adds test feature --- Cargo.toml | 1 + src/influx.rs | 6 +++--- src/lib.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8f3b9b..688226b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,4 @@ pubsub = { path = "../pubsub" } [features] no-thrash = [] trace = [] +test = [] diff --git a/src/influx.rs b/src/influx.rs index 8624db6..088492c 100644 --- a/src/influx.rs +++ b/src/influx.rs @@ -216,12 +216,12 @@ impl InfluxWriter { let (tx, rx) = channel(); let logger = file_logger(log_path, Severity::Info); let thread = thread::spawn(move || { - info!(logger, "initializing url"; + debug!(logger, "initializing url"; "DB_HOST" => host, "DB_NAME" => db); let url = Url::parse_with_params(&format!("http://{}:8086/write", host), &[("db", db), ("precision", "ns")]).expect("influx writer url should parse"); let client = Client::new(); - info!(logger, "initializing buffers"); + debug!(logger, "initializing buffers"); let mut meas_buf = String::with_capacity(32 * 32 * 32); let mut buf = String::with_capacity(32 * 32 * 32); let mut count = 0; @@ -319,7 +319,7 @@ impl InfluxWriter { } } - crit!(logger, "goodbye"); + debug!(logger, "goodbye"); }); InfluxWriter { diff --git a/src/lib.rs b/src/lib.rs index 1bf90b5..4149355 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,7 +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))] +#[cfg(not(any(test, feature = "test")))] pub fn file_logger(path: &str, level: Severity) -> slog::Logger { let mut builder = FileLoggerBuilder::new(path); builder.level(level); @@ -53,7 +53,7 @@ pub fn file_logger(path: &str, level: Severity) -> slog::Logger { } -#[cfg(test)] +#[cfg(any(test, feature = "test"))] pub fn file_logger(path: &str, level: Severity) -> slog::Logger { use slog::*; Logger::root(Discard, o!())