From 7a0684371f0f98d1a308478729a7f97f09f2309d Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Tue, 1 Jan 2019 04:34:12 -0500 Subject: [PATCH] adds `pub fn rotating_file_logger

(path: P, level: Severity, compress: bool) -> slog::Logger` allows optional compression on rotated logfiles --- Cargo.toml | 2 +- src/lib.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4fcac7d..3856ffe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "logging" -version = "0.5.1" +version = "0.5.2" authors = ["Jonathan Strong "] edition = "2018" diff --git a/src/lib.rs b/src/lib.rs index 54024b1..83868f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,13 +65,17 @@ pub fn inanos(t: DateTime) -> i64 { //#[cfg(not(any(test, feature = "test")))] pub fn file_logger>(path: P, level: Severity) -> slog::Logger { + rotating_file_logger(path, level, true) +} + +pub fn rotating_file_logger>(path: P, level: Severity, compress: bool) -> slog::Logger { let mut builder = FileLoggerBuilder::new(path); builder.level(level) .timezone(TimeZone::Utc) .channel_size(CHANNEL_SIZE) .rotate_size(1024 * 1024 * 1024) .rotate_keep(1000) - .rotate_compress(true) + .rotate_compress(compress) .source_location(sloggers::types::SourceLocation::ModuleAndLine); builder.build().unwrap() // the sloggers impl can't actually fail (v0.3) }