#logger #stores #file #writer #cleanup #flexi-logger #day

flexi_logger_rotate_writer

A custom log writer for emabee’s flexi_logger. It is just a simplified version of flexi_logger’s FileLogWriter. Simply rotates every day, and stores the logs in files like foo_r2021-03-28.log. No cleanup. No other configs.

1 unstable release

0.0.0 Mar 28, 2021

#47 in #stores

MIT license

18KB
353 lines

flexi_logger_rotate_writer

A custom log writer for emabee's flexi_logger.

It is just a simplified version of flexi_logger's FileLogWriter. Simply rotates every day, and stores the logs in files like foo_r2021-03-28.log. No cleanup. No other configs.

Most of the codes are directly taken from flexi_logger, with some modification.

Example usage

use flexi_logger_rotate_writer::RotateLogWriter;
use flexi_logger::{Logger, LogTarget};

fn main() {
    let log_writer = RotateLogWriter::builder()
        .directory("path/to/where/you/want/to/store/the/log/files")
        // Some other configs...
        .try_build()?;

    Logger::with_env()
        .log_target(LogTarget::Writer(Box::new(log_writer)))
        // Some other configs...
        .start()?;

    // ...
}

lib.rs:

A custom log writer for emabee's flexi_logger.

It is just a simplified version of flexi_logger's FileLogWriter. Simply rotates every day, and stores the logs in files like foo_r2021-03-28.log. No cleanup. No other configs.

Example usage

use flexi_logger_rotate_writer::RotateLogWriter;
use flexi_logger::{Logger, LogTarget};

let log_writer = RotateLogWriter::builder()
    .directory("path/to/where/you/want/to/store/the/log/files")
    // Some other configs...
    .try_build()
    .unwrap();

Logger::with_env()
    .log_target(LogTarget::Writer(Box::new(log_writer)))
    // Some other configs...
    .start()
    .unwrap();

// ...

Dependencies

~1.7–2.4MB
~45K SLoC