Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
414 stars 71 forks source link

The `new` method of loggers are now `#[must_use]` #116

Closed softdevca closed 1 year ago

softdevca commented 1 year ago

The new method of loggers are now #[must_use] to prevent confusion when new is used called instead of init.

Currently the following code will appear completely valid but silently not do any logging:

use log::*;
use simplelog::*;

fn main() {
    TermLogger::new(
        LevelFilter::Trace,
        Config::default(),
        TerminalMode::Stdout,
        ColorChoice::Auto,
    );
    error!("Red error");
    warn!("Yellow warning");
    info!("Blue info");
    debug!("Cyan debug");
    trace!("White trace");
}

With this change a compiler warning is generated on new.

coveralls commented 1 year ago

Coverage Status

Coverage remained the same at 53.947% when pulling 80242aab3cd860e40208af4b2069d1b49a1be14a on softdevca:pr-must_use-new into 626467d20046edb9c020acfbae461c2dd9cb2e17 on Drakulix:master.

Drakulix commented 1 year ago

Thanks!