Browse Source

adds test feature

master
Jonathan Strong 6 years ago
parent
commit
5b716e411b
3 changed files with 6 additions and 5 deletions
  1. +1
    -0
      Cargo.toml
  2. +3
    -3
      src/influx.rs
  3. +2
    -2
      src/lib.rs

+ 1
- 0
Cargo.toml View File

@@ -27,3 +27,4 @@ pubsub = { path = "../pubsub" }
[features]
no-thrash = []
trace = []
test = []

+ 3
- 3
src/influx.rs View File

@@ -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 {


+ 2
- 2
src/lib.rs View File

@@ -44,7 +44,7 @@ pub fn nanos(t: DateTime<Utc>) -> 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!())


Loading…
Cancel
Save