#logging #fmt #logger #log-file #async #log-level #color

bin+lib unilog

A lightweight Rust logging library supporting async/sync logging and colored logs

1 unstable release

new 0.1.3 Feb 17, 2025

#843 in Debugging

Download history 51/week @ 2025-02-12

51 downloads per month

MIT license

13KB
206 lines

🦀unilog.rs

Example

use unilog::{Level, UniLog, Fatal, Error, Warn, Notice, Info, Debug, Trace};

fn main() {
    let instance = UniLog::init()
        .set_log_file_name("server.log") // dont forget the file extension
        .log_to_terminal(true)
        .async_logging()
        .enable_timestamping()
        .enable_colored_logs()
        .max_log_file_size(20) // 20 Mb, would truncate the log file if its size exceeds this limit!
    ;

    Fatal! (instance, "TRIAL of fatal error via macros !!");
    Notice!(instance, "TRIAL of notices lets see what happens !!");
    Warn!  (instance, "TRIAL of warnings lets see what happens !!");
    Info!  (instance, "TRIAL of information lets see what happens !!");
    Debug! (instance, "TRIAL of debugging lets see what happens !!");
    Error! (instance, "TRIAL of error lets see what happens !!");
    Trace! (instance, "TRIAL of tracing lets see what happens !!");
}

Dependencies

~1MB
~18K SLoC