From dbd72c21fa5ac133c12eae578ab593d3d9b43e54 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Fri, 14 Dec 2018 05:39:14 -0500 Subject: [PATCH] upgrade sloggers to v0.3 and use new log rotation/compression features --- Cargo.toml | 5 +++-- src/lib.rs | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fada33b..4fcac7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "logging" -version = "0.5.0" +version = "0.5.1" authors = ["Jonathan Strong "] edition = "2018" @@ -32,7 +32,8 @@ dirs = "1" crossbeam-channel = "0.3" pretty_toa = "1.0.0" -sloggers = { path = "../sloggers" } +sloggers = "0.3" +#sloggers = { path = "../sloggers" } decimal = { path = "../decimal", version = "2" } diff --git a/src/lib.rs b/src/lib.rs index d91afe8..0478fef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,12 +64,16 @@ pub fn inanos(t: DateTime) -> i64 { } //#[cfg(not(any(test, feature = "test")))] -pub fn file_logger(path: &str, level: Severity) -> slog::Logger { +pub fn file_logger>(path: P, level: Severity) -> slog::Logger { let mut builder = FileLoggerBuilder::new(path); - builder.level(level); - builder.timezone(TimeZone::Utc); - builder.channel_size(CHANNEL_SIZE); - builder.build().unwrap() + builder.level(level) + .timezone(TimeZone::Utc) + .channel_size(CHANNEL_SIZE) + .rotate_size(1024 * 1024 * 1024) + .rotate_keep(1000) + .rotate_compress(true) + .source_location(sloggers::types::SourceLocation::ModuleAndLine); + builder.build().unwrap() // the sloggers impl can't actually fail (v0.3) } pub fn truncating_file_logger(path: &str, level: Severity) -> slog::Logger {