Crate rf_logger

Source
Expand description

A simple logger that can log to stdout, stderr and rotated files, for use with the logging facade exposed by the log crate.

§Example

use log::{LevelFilter, info};
use rf_logger;
 
rf_logger::Builder::new()
	.max_level(LevelFilter::Debug)
	.stdout()
	.rotated_file("tests/demo.log", 5 * 1024, 3)
	.init();
	
info!("Hello, rf_logger");
info!("Bye");

§Enabling logging

Log levels are controlled on a per-module basis, and by default all logging is disabled except for the error level.

Log levels should be set by Builder::max_level()

§Formatting

Time formatting string can be set via Builder::time_fmt() while other parts are fixed.

let _ = writeln!(
	buf,
	"{} - {} - {}",
	now.format(&self.time_fmt),
	record.level(),
	record.args()
);

§Notes

There is a mutex lock during every log record beening handled, if performance is what your concern this crate may not be a good choice.

Structs§

Builder
Builder acts as builder for initializing a Logger.