1 unstable release

0.7.1 Nov 10, 2022
0.6.3 Sep 19, 2022
0.5.0 May 20, 2021
0.4.0 Mar 8, 2021
0.0.1 Jul 6, 2020

#635 in Debugging

Download history 68/week @ 2024-07-01 8/week @ 2024-07-08 27/week @ 2024-07-15 18/week @ 2024-07-22 131/week @ 2024-07-29 23/week @ 2024-08-05 25/week @ 2024-08-12 5/week @ 2024-08-19 49/week @ 2024-08-26 39/week @ 2024-09-02 42/week @ 2024-09-09 12/week @ 2024-09-16 67/week @ 2024-09-23 23/week @ 2024-09-30 14/week @ 2024-10-07 32/week @ 2024-10-14

137 downloads per month
Used in 3 crates

MIT license

8KB
115 lines

logs

Crates.io docs.rs Crates.io

A simple terminal logger

Usage

Add this in your Cargo.toml:

[dependencies]
logs = "*"

Example

use logs::{debug, error, info, trace, warn, Logs};

fn main() {
    Logs::new().init();

    trace!("This is a trace log");
    debug!("This is a debug log");
    info!("This is a info log");
    warn!("This is a warn log");
    error!("This is a error log");
}

Output:

2022-09-06T08:38:23.490 [TRACE] This is a trace log
2022-09-06T08:38:23.490 [DEBUG] This is a debug log
2022-09-06T08:38:23.490 [INFO ] This is a info log
2022-09-06T08:38:23.490 [WARN ] This is a warn log
2022-09-06T08:38:23.490 [ERROR] This is a error log

Options

use logs::{Logs, debug, error, LevelFilter};

fn main() {
    Logs::new()
        // Show log level color
        .color(true)
        // Filter log target
        .target("target")
        // Filter log level
        .level(LevelFilter::Info)
        // Filter log target from `LOG` environment variable
        .level_from_default_env()
        .unwrap()
        // Filter log target from `NAME` environment variable
        .level_from_env("NAME")
        .unwrap()
        // Filter log level from str
        .level_from_str("info")
        .unwrap()
        // Apply
        .init();
}

Dependencies

~1MB
~15K SLoC