@@ -16,6 +16,7 @@ use hyper::client::Client; | |||||
use influent::measurement::{Measurement, Value}; | use influent::measurement::{Measurement, Value}; | ||||
use zmq; | use zmq; | ||||
use chrono::{DateTime, Utc, TimeZone}; | use chrono::{DateTime, Utc, TimeZone}; | ||||
use sloggers::types::Severity; | |||||
use super::{nanos, file_logger}; | use super::{nanos, file_logger}; | ||||
use warnings::Warning; | use warnings::Warning; | ||||
@@ -294,7 +295,7 @@ pub fn dur_nanos(d: ::std::time::Duration) -> i64 { | |||||
/// | /// | ||||
pub fn writer_str_or_meas(log_path: &str, warnings: Sender<Warning>) -> (thread::JoinHandle<()>, Sender<OwnedMeasurement>) { | pub fn writer_str_or_meas(log_path: &str, warnings: Sender<Warning>) -> (thread::JoinHandle<()>, Sender<OwnedMeasurement>) { | ||||
let (tx, rx) = channel(); | let (tx, rx) = channel(); | ||||
let logger = file_logger(log_path); | |||||
let logger = file_logger(log_path, Severity::Info); | |||||
let thread = thread::spawn(move || { | let thread = thread::spawn(move || { | ||||
info!(logger, "initializing zmq"); | info!(logger, "initializing zmq"); | ||||
let _ = fs::create_dir("/tmp/mm"); | let _ = fs::create_dir("/tmp/mm"); | ||||
@@ -350,19 +351,6 @@ pub fn writer_str_or_meas(log_path: &str, warnings: Sender<Warning>) -> (thread: | |||||
error!(logger, "influx server error"; | error!(logger, "influx server error"; | ||||
"status" => resp.status.to_string(), | "status" => resp.status.to_string(), | ||||
"body" => server_resp); | "body" => server_resp); | ||||
// OpenOptions::new() | |||||
// .create(true) | |||||
// .append(true) | |||||
// .open("/home/jstrong/src/market-maker/influx-errors.txt") | |||||
// .map_err(|e| { | |||||
// warnings.send(Warning::Error(format!("failed to save influx error: {}", e))); | |||||
// }).map(|mut file| { | |||||
// write!(file, "{}", server_resp); | |||||
// }); | |||||
// server_resp.truncate(120); | |||||
// warnings.send( | |||||
// Warning::Error( | |||||
// format!("Influx server: {}", server_resp))); | |||||
} | } | ||||
Err(why) => { | Err(why) => { | ||||
@@ -9,6 +9,7 @@ use chrono::{self, DateTime, Utc, TimeZone}; | |||||
use pub_sub::PubSub; | use pub_sub::PubSub; | ||||
use zmq; | use zmq; | ||||
use influent::measurement::{Measurement, Value}; | use influent::measurement::{Measurement, Value}; | ||||
use sloggers::types::Severity; | |||||
use windows::{DurationWindow, Incremental}; | use windows::{DurationWindow, Incremental}; | ||||
use money::{Ticker, Side, ByExchange, Exchange}; | use money::{Ticker, Side, ByExchange, Exchange}; | ||||
@@ -340,7 +341,7 @@ impl Manager { | |||||
let tx_copy = tx.clone(); | let tx_copy = tx.clone(); | ||||
let channel = PubSub::new(); | let channel = PubSub::new(); | ||||
let channel_copy = channel.clone(); | let channel_copy = channel.clone(); | ||||
let logger = file_logger(log_path); | |||||
let logger = file_logger(log_path, Severity::Info); | |||||
info!(logger, "initializing"); | info!(logger, "initializing"); | ||||
@@ -429,7 +430,7 @@ impl LatencyManager<WTen> { | |||||
let w = w.clone(); | let w = w.clone(); | ||||
let thread = Some(thread::spawn(move || { | let thread = Some(thread::spawn(move || { | ||||
let logger = file_logger("var/log/latency-manager.log"); | |||||
let logger = file_logger("var/log/latency-manager.log", Severity::Info); | |||||
info!(logger, "initializing zmq"); | info!(logger, "initializing zmq"); | ||||
let ctx = zmq::Context::new(); | let ctx = zmq::Context::new(); | ||||
@@ -36,9 +36,9 @@ pub fn nanos(t: DateTime<Utc>) -> u64 { | |||||
(t.timestamp() as u64) * 1_000_000_000_u64 + (t.timestamp_subsec_nanos() as u64) | (t.timestamp() as u64) * 1_000_000_000_u64 + (t.timestamp_subsec_nanos() as u64) | ||||
} | } | ||||
pub fn file_logger(path: &str) -> slog::Logger { | |||||
pub fn file_logger(path: &str, level: Severity) -> slog::Logger { | |||||
let mut builder = FileLoggerBuilder::new(path); | let mut builder = FileLoggerBuilder::new(path); | ||||
builder.level(Severity::Debug); | |||||
builder.level(level); | |||||
builder.timezone(TimeZone::Utc); | builder.timezone(TimeZone::Utc); | ||||
builder.build().unwrap() | builder.build().unwrap() | ||||
} | } |
@@ -12,6 +12,7 @@ use chrono::{DateTime, Utc, TimeZone}; | |||||
use termion::color::{self, Fg, Bg}; | use termion::color::{self, Fg, Bg}; | ||||
use influent::measurement::{Measurement, Value as InfluentValue}; | use influent::measurement::{Measurement, Value as InfluentValue}; | ||||
use slog::{self, OwnedKVList, Drain, Key, KV}; | use slog::{self, OwnedKVList, Drain, Key, KV}; | ||||
use sloggers::types::Severity; | |||||
use super::{nanos, file_logger}; | use super::{nanos, file_logger}; | ||||
use influx; | use influx; | ||||
@@ -382,7 +383,7 @@ impl WarningsManager { | |||||
let socket = influx::push(&ctx).unwrap(); | let socket = influx::push(&ctx).unwrap(); | ||||
let thread = thread::spawn(move || { | let thread = thread::spawn(move || { | ||||
let path = format!("var/log/warnings-manager-{}.log", measurement_name); | let path = format!("var/log/warnings-manager-{}.log", measurement_name); | ||||
let logger = file_logger(&path); | |||||
let logger = file_logger(&path, Severity::Info); | |||||
info!(logger, "entering loop"); | info!(logger, "entering loop"); | ||||
loop { | loop { | ||||
if let Ok(msg) = rx.recv() { | if let Ok(msg) = rx.recv() { | ||||