Browse Source

upgrade sloggers to v0.3 and use new log rotation/compression features

master
Jonathan Strong 5 years ago
parent
commit
dbd72c21fa
2 changed files with 12 additions and 7 deletions
  1. +3
    -2
      Cargo.toml
  2. +9
    -5
      src/lib.rs

+ 3
- 2
Cargo.toml View File

@@ -1,6 +1,6 @@
[package]
name = "logging"
version = "0.5.0"
version = "0.5.1"
authors = ["Jonathan Strong <jonathan.strong@gmail.com>"]
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" }



+ 9
- 5
src/lib.rs View File

@@ -64,12 +64,16 @@ pub fn inanos(t: DateTime<Utc>) -> i64 {
}

//#[cfg(not(any(test, feature = "test")))]
pub fn file_logger(path: &str, level: Severity) -> slog::Logger {
pub fn file_logger<P: AsRef<std::path::Path>>(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 {


Loading…
Cancel
Save