d_logger
A rust crate providing simple logging with a dated clean up util.
Examples
Create a logger with 7 days of cleaning
use Logger;
let logger = new.unwrap;
if !logger.write_log
// This will work
logger.log_clean;
Create a logger without any cleaning
use Logger;
let logger = new.unwrap;
if !logger.write_log
// This will fail
logger.log_clean;
Clean logs with a regex filter
use Logger;
let logger = new.unwrap;
if !logger.write_log
// This will work
logger.log_clean;
Functions
new(path: String, file_name_format: String, line_date_format: String, days_keep: Option) -> Result<Logger, io::error>
Create a new logging structure and test that the path and file given can be accessed.
write_log(line: String) -> bool
Write a line to the log file. Will return whether its successful
log_clean(regex: Option<&str>)
Clean up the log directory. If regex is provided only files matching regex will be deleted. Will only delete anything if days_keep was set. The files delete must be older than the number of days wanted to keep.