#logger #logging #development-tools-debuggings

lawg

lawg is a Rust library designed to log and create log files with ease

1 unstable release

0.1.0 Nov 8, 2021

#191 in #logger

MIT/Apache

12KB
174 lines

lawg

lawg is a Rust library designed to log and create log files with ease.

Example

use lawg::Logger;

fn main() {
    let logger = Logger::new(String::from("General Logger"), Some(String::from("logs.txt")), true);

    logger.log("Started"); // My Logger - ["yyyy-mm-dd hh:mm:ss UTC"]: Started
    logger.log_to_file("Started again");

    let mut x = 1 + 1;

    if x == 2 {
        logger.log_and_log_to_file(String::from("It is two")); // My Logger - ["yyyy-mm-dd hh:mm:ss UTC"]: It is two
    } else {
        logger.error_and_stop("1 + 1 is not two"); // ERROR: My Logger - ["yyyy-mm-dd hh:mm:ss UTC"]: 1 + 1 is not two
    }
}

lib.rs:

lawg is a Rust library designed to log and create log files with ease.

Example

use lawg::Logger;

fn main() {
    let logger = Logger::new(String::from("General Logger"), Some(String::from("../logs/general/logs.txt")), true);

    logger.log("Started"); // My Logger - ["yyyy-mm-dd hh:mm:ss UTC"]: Started
    logger.log_to_file("Started again");

    let mut x = 1 + 1;

    if x == 2 {
        logger.log_and_log_to_file(String::from("It is two")); // My Logger - ["yyyy-mm-dd hh:mm:ss UTC"]: It is two
    } else {
        logger.error_and_stop("1 + 1 is not two"); // ERROR: My Logger - ["yyyy-mm-dd hh:mm:ss UTC"]: 1 + 1 is not two
    }
}

Dependencies

~1MB
~18K SLoC