easy-logging

Crates.ioeasy-logging
lib.rseasy-logging
version1.0.0
sourcesrc
created_at2018-09-30 20:15:38.465336
updated_at2024-08-02 05:23:41.020928
descriptionAn easy way to get logging working in your CLI tool
homepage
repositoryhttps://github.com/KonishchevDmitry/rust-easy-logging
max_upload_size
id87328
size10,212
Dmitry Konishchev (KonishchevDmitry)

documentation

README

easy-logging

An easy way to get logging working in your command line tool. Suitable for simple CLI and prototyping.

Requires a single function call and provides colored logging to stdout/stderr out of the box.

Usage

Add to your Cargo.toml:

[dependencies]
easy-logging = "1"

Example:

use log::{Level, debug, info};

fn main() {
    easy_logging::init(module_path!(), Level::Info).unwrap();
    debug!("Test debug message.");
    info!("Test info message.");
}

Output with enabled info level:

I: Test info message.

Output with enabled debug level:

[22:29:18.084] [   main.rs:006] D: Test debug message.
[22:29:18.085] [   main.rs:007] I: Test info message.
Commit count: 3

cargo fmt