@@ -11,7 +11,7 @@ hyper = "0.10" | |||||
termion = "1.4.0" | termion = "1.4.0" | ||||
# pub-sub = "2.0" | # pub-sub = "2.0" | ||||
slog = "2.0.6" | slog = "2.0.6" | ||||
sloggers = "0.2" | |||||
# sloggers = "0.2" | |||||
slog-term = "2" | slog-term = "2" | ||||
# chashmap = "2" | # chashmap = "2" | ||||
ordermap = "0.3" | ordermap = "0.3" | ||||
@@ -20,6 +20,8 @@ uuid = { version = "0.5", features = ["serde", "v4"] } | |||||
hdrhistogram = "6" | hdrhistogram = "6" | ||||
slog-async = "2" | slog-async = "2" | ||||
sloggers = { path = "../sloggers" } | |||||
decimal = { path = "../decimal", version = "2" } | decimal = { path = "../decimal", version = "2" } | ||||
windows = { path = "../windows", version = "0.1" } | windows = { path = "../windows", version = "0.1" } | ||||
@@ -35,3 +37,4 @@ localhost = [] | |||||
harrison = [] | harrison = [] | ||||
washington = [] | washington = [] | ||||
scholes = [] | scholes = [] | ||||
no-influx-buffer = [] |
@@ -234,7 +234,10 @@ impl InfluxWriter { | |||||
pub fn new(host: &'static str, db: &'static str, log_path: &str, buffer_size: u16) -> Self { | pub fn new(host: &'static str, db: &'static str, log_path: &str, buffer_size: u16) -> Self { | ||||
let (tx, rx): (Sender<Option<OwnedMeasurement>>, Receiver<Option<OwnedMeasurement>>) = channel(); | let (tx, rx): (Sender<Option<OwnedMeasurement>>, Receiver<Option<OwnedMeasurement>>) = channel(); | ||||
let logger = file_logger(log_path, LOG_LEVEL); // this needs to be outside the thread | 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 || { | let thread = thread::Builder::new().name(format!("mm:inflx:{}", db)).spawn(move || { | ||||
debug!(logger, "initializing url"; | debug!(logger, "initializing url"; | ||||
"DB_HOST" => host, | "DB_HOST" => host, | ||||
@@ -62,12 +62,22 @@ pub fn file_logger(path: &str, level: Severity) -> slog::Logger { | |||||
builder.build().unwrap() | 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"))] | // #[cfg(any(test, feature = "test"))] | ||||
// pub fn file_logger(_: &str, _: Severity) -> slog::Logger { | // pub fn file_logger(_: &str, _: Severity) -> slog::Logger { | ||||
// use slog::*; | // use slog::*; | ||||
// Logger::root(Discard, o!()) | // 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 { | pub fn async_file_logger(path: &str, level: Severity) -> slog::Logger { | ||||
let drain = file_logger(path, level); | let drain = file_logger(path, level); | ||||
let async_drain = | let async_drain = | ||||