diff --git a/Cargo.toml b/Cargo.toml index 41e2674..c50c0d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ hyper = "0.10" termion = "1.4.0" # pub-sub = "2.0" slog = "2.0.6" -sloggers = "0.2" +# sloggers = "0.2" slog-term = "2" # chashmap = "2" ordermap = "0.3" @@ -20,6 +20,8 @@ uuid = { version = "0.5", features = ["serde", "v4"] } hdrhistogram = "6" slog-async = "2" +sloggers = { path = "../sloggers" } + decimal = { path = "../decimal", version = "2" } windows = { path = "../windows", version = "0.1" } @@ -35,3 +37,4 @@ localhost = [] harrison = [] washington = [] scholes = [] +no-influx-buffer = [] diff --git a/src/influx.rs b/src/influx.rs index 7118a6a..f1062f9 100644 --- a/src/influx.rs +++ b/src/influx.rs @@ -234,7 +234,10 @@ impl InfluxWriter { pub fn new(host: &'static str, db: &'static str, log_path: &str, buffer_size: u16) -> Self { let (tx, rx): (Sender>, Receiver>) = channel(); let logger = file_logger(log_path, LOG_LEVEL); // this needs to be outside the thread - let buffer_size = if cfg!(feature = "trace") { 0u16 } else { buffer_size }; + + #[cfg(feature = "no-influx-buffer")] + let buffer_size = 0u16; + let thread = thread::Builder::new().name(format!("mm:inflx:{}", db)).spawn(move || { debug!(logger, "initializing url"; "DB_HOST" => host, diff --git a/src/lib.rs b/src/lib.rs index c5ba48e..a315e9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,12 +62,22 @@ pub fn file_logger(path: &str, level: Severity) -> slog::Logger { builder.build().unwrap() } +pub fn truncating_file_logger(path: &str, level: Severity) -> slog::Logger { + let mut builder = FileLoggerBuilder::new(path); + builder.level(level); + builder.timezone(TimeZone::Utc); + builder.truncate(); + builder.build().unwrap() +} + // #[cfg(any(test, feature = "test"))] // pub fn file_logger(_: &str, _: Severity) -> slog::Logger { // use slog::*; // Logger::root(Discard, o!()) // } +#[deprecated(since="0.4.0", note="Turns out the file logger in sloggers uses async, \ + making the async here duplicative")] pub fn async_file_logger(path: &str, level: Severity) -> slog::Logger { let drain = file_logger(path, level); let async_drain =