Browse Source

adds async_file_logger fn

master
Jonathan Strong 6 years ago
parent
commit
4a6498a6f1
2 changed files with 12 additions and 0 deletions
  1. +1
    -0
      Cargo.toml
  2. +11
    -0
      src/lib.rs

+ 1
- 0
Cargo.toml View File

@@ -18,6 +18,7 @@ ordermap = "0.3"
fnv = "1"
uuid = { version = "0.5", features = ["serde", "v4"] }
hdrsample = "6"
slog-async = "2"

decimal = { path = "../decimal", version = "2" }



+ 11
- 0
src/lib.rs View File

@@ -16,6 +16,7 @@ extern crate hyper;
extern crate termion;
extern crate sloggers;
extern crate slog_term;
extern crate slog_async;
extern crate fnv;
extern crate ordermap;
extern crate decimal;
@@ -33,6 +34,7 @@ pub use sloggers::types::Severity;
use sloggers::types::TimeZone;
#[allow(unused_imports)]
use sloggers::file::FileLoggerBuilder;
use slog::Drain;

pub mod influx;
pub mod warnings;
@@ -59,6 +61,15 @@ pub fn file_logger(_: &str, _: Severity) -> slog::Logger {
Logger::root(Discard, o!())
}

pub fn async_file_logger(path: &str, level: Severity) -> slog::Logger {
let drain = file_logger(path, level);
let async_drain =
slog_async::Async::new(drain)
.chan_size(100_000)
.build();
slog::Logger::root(async_drain.fuse(), o!())
}

pub fn dt_nanos(t: DateTime<Utc>) -> i64 {
(t.timestamp() as i64) * 1_000_000_000_i64 + (t.timestamp_subsec_nanos() as i64)
}


Loading…
Cancel
Save