Browse Source

changes severity to info for file loggers

master
Jonathan Strong 7 years ago
parent
commit
1b5050d127
4 changed files with 9 additions and 19 deletions
  1. +2
    -14
      src/influx.rs
  2. +3
    -2
      src/latency.rs
  3. +2
    -2
      src/lib.rs
  4. +2
    -1
      src/warnings.rs

+ 2
- 14
src/influx.rs View File

@@ -16,6 +16,7 @@ use hyper::client::Client;
use influent::measurement::{Measurement, Value};
use zmq;
use chrono::{DateTime, Utc, TimeZone};
use sloggers::types::Severity;

use super::{nanos, file_logger};
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>) {
let (tx, rx) = channel();
let logger = file_logger(log_path);
let logger = file_logger(log_path, Severity::Info);
let thread = thread::spawn(move || {
info!(logger, "initializing zmq");
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";
"status" => resp.status.to_string(),
"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) => {


+ 3
- 2
src/latency.rs View File

@@ -9,6 +9,7 @@ use chrono::{self, DateTime, Utc, TimeZone};
use pub_sub::PubSub;
use zmq;
use influent::measurement::{Measurement, Value};
use sloggers::types::Severity;

use windows::{DurationWindow, Incremental};
use money::{Ticker, Side, ByExchange, Exchange};
@@ -340,7 +341,7 @@ impl Manager {
let tx_copy = tx.clone();
let channel = PubSub::new();
let channel_copy = channel.clone();
let logger = file_logger(log_path);
let logger = file_logger(log_path, Severity::Info);
info!(logger, "initializing");
@@ -429,7 +430,7 @@ impl LatencyManager<WTen> {
let w = w.clone();

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");

let ctx = zmq::Context::new();


+ 2
- 2
src/lib.rs View File

@@ -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)
}

pub fn file_logger(path: &str) -> slog::Logger {
pub fn file_logger(path: &str, level: Severity) -> slog::Logger {
let mut builder = FileLoggerBuilder::new(path);
builder.level(Severity::Debug);
builder.level(level);
builder.timezone(TimeZone::Utc);
builder.build().unwrap()
}

+ 2
- 1
src/warnings.rs View File

@@ -12,6 +12,7 @@ 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};
use sloggers::types::Severity;

use super::{nanos, file_logger};
use influx;
@@ -382,7 +383,7 @@ impl WarningsManager {
let socket = influx::push(&ctx).unwrap();
let thread = thread::spawn(move || {
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");
loop {
if let Ok(msg) = rx.recv() {


Loading…
Cancel
Save