From 3aebc4211372f753df33a84daf904898999a49ec Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Fri, 22 Sep 2017 01:20:49 -0400 Subject: [PATCH] writes bad stuff to file --- src/warnings.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/warnings.rs b/src/warnings.rs index 6c6cab0..161dcb3 100644 --- a/src/warnings.rs +++ b/src/warnings.rs @@ -13,7 +13,7 @@ use zmq; use chrono::{DateTime, Utc, TimeZone}; use termion::color::{self, Fg, Bg}; use influent::measurement::{Measurement, Value as InfluentValue}; -use slog::{self, OwnedKVList, Drain, Key, KV, Level}; +use slog::{self, OwnedKVList, Drain, Key, KV, Level, Logger}; use sloggers::types::Severity; use super::{nanos, file_logger}; @@ -363,7 +363,8 @@ impl<'a> slog::Serializer for TagBuilder<'a> { pub struct WarningsDrain { level: Level, tx: Arc>>, - drain: D + drain: D, + to_file: Logger, } impl WarningsDrain @@ -371,7 +372,8 @@ impl WarningsDrain { pub fn new(tx: Sender, level: Level, drain: D) -> Self { let tx = Arc::new(Mutex::new(tx)); - WarningsDrain { tx, drain, level } + let to_file = file_logger("var/log/mm.log", Severity::Warning); + WarningsDrain { tx, drain, level, to_file } } } @@ -402,6 +404,9 @@ impl Drain for WarningsDrain { }); } } + if record.level() <= Level::Warning { + let _ = self.to_file.log(record); + } let _ = self.drain.log(record, values)?; Ok(()) }