#logger #log #pipe #logrotate #rotation

pipe-logger-lib

Stores, rotates, compresses process logs

10 stable releases

1.1.5 Nov 14, 2018
1.1.4 Sep 13, 2018
1.1.2 Sep 12, 2018
1.0.3 Sep 12, 2018

#65 in Debugging

Download history 42/week @ 2018-10-15 30/week @ 2018-10-22 87/week @ 2018-10-29 64/week @ 2018-11-05 31/week @ 2018-11-12 12/week @ 2018-11-19 76/week @ 2018-11-26 21/week @ 2018-12-03 21/week @ 2018-12-10 14/week @ 2018-12-17 60/week @ 2018-12-24 1/week @ 2018-12-31 12/week @ 2019-01-07 3/week @ 2019-01-14 1/week @ 2019-01-21

161 downloads per month
Used in 1 crate

MIT license

26KB
437 lines

Pipe Logger Lib

Build Status Build status

Stores, rotates, compresses process logs.

Example

extern crate pipe_logger_lib;

use pipe_logger_lib::*;

use std::fs;
use std::path::Path;

let test_folder = {
  let folder = Path::join(&Path::join(Path::new("tests"), Path::new("out")), "log-example");

  fs::remove_dir_all(&folder);

  fs::create_dir_all(&folder).unwrap();

  folder
};

let test_log_file = Path::join(&test_folder, Path::new("mylog.txt"));

let mut builder = PipeLoggerBuilder::new(&test_log_file);

builder
    .set_tee(Some(Tee::Stdout))
    .set_rotate(Some(RotateMethod::FileSize(30))) // bytes
    .set_count(Some(10))
    .set_compress(false);

{
    let mut logger = builder.build().unwrap();

    logger.write_line("Hello world!").unwrap();

    let rotated_log_file_1 = logger.write_line("This is a convenient logger.").unwrap().unwrap();

    logger.write_line("Other logs...").unwrap();
    logger.write_line("Other logs...").unwrap();

    let rotated_log_file_2 = logger.write_line("Rotate again!").unwrap().unwrap();

    logger.write_line("Ops!").unwrap();
}

fs::remove_dir_all(test_folder).unwrap();

Now, the contents of test_log_file are,

Ops!

The contents of rotated_log_file_1 are,

Hello world!
This is a convenient logger.

The contents of rotated_log_file_2 are,

Other logs...
Other logs...
Rotate again!

Crates.io

https://crates.io/crates/pipe-logger-lib

Documentation

https://docs.rs/pipe-logger-lib

Official CLI

https://crates.io/crates/pipe-logger

License

MIT

Dependencies

~3.5MB
~69K SLoC