flexi_logger 0.10.4

An easy-to-configure and flexible logger that writes logs to stderr and/or to files. It allows custom logline formats, and it allows changing the log specification at runtime. It also allows defining additional log streams, e.g. for alert or security messages.
Documentation
extern crate flexi_logger;
#[macro_use]
extern crate log;

use flexi_logger::{opt_format, Logger};

#[test]
fn test_opt_files_dir_dscr_rot() {
    let link_name = "link_to_log".to_string();
    let handle = Logger::with_str("info")
        .format(opt_format)
        .log_to_file()
        .directory("log_files")
        .discriminant("foo".to_string())
        .rotate_over_size(2000)
        .create_symlink(link_name.clone())
        .start_reconfigurable()
        .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));

    error!("This is an error message");
    warn!("This is a warning");
    info!("This is an info message");
    debug!("This is a debug message - you must not see it!");
    trace!("This is a trace message - you must not see it!");
    handle.validate_logs(&[
        ("ERROR", "test_opt_files_dir_dscr_rot", "error"),
        ("WARN", "test_opt_files_dir_dscr_rot", "warning"),
        ("INFO", "test_opt_files_dir_dscr_rot", "info"),
    ]);
    self::platform::check_link(&link_name);
}

mod platform {
    #[cfg(target_os = "linux")]
    pub fn check_link(link_name: &str) {
        use std::fs;
        assert!(fs::metadata(link_name).is_ok());
    }

    #[cfg(not(target_os = "linux"))]
    pub fn check_link(_: &str) {}
}