Drakulix / simplelog.rs

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

Regression: No log output for format "%z", "%:z", "%Z" or "%+" #49

Closed timokroeger closed 5 years ago

timokroeger commented 5 years ago

A logger configured with any timezone related output format does not work. No output can be seen on the terminal for a TermLogger. No output is written to the logfile for a WriteLogger.

Example:

// Setup logging: Use local time in RFC3339 format
let log_config = LogConfigBuilder::new()
    .set_time_to_local(true)
    .set_time_format_str("%Y-%m-%dT%H:%M:%S%.3f%:z")
    .build();

As soon as I remove the last "%:z" the logger works as expected.

Tested version: 0.7.3 Version 0.5 and 0.6 work just fine with those format specifiers.

AlexanderThaller commented 5 years ago

Have the same problem with this setup

fn main() {
    let config = simplelog::ConfigBuilder::new()
        .set_time_format("%+".to_string())
        .build();

    println!("config: {:#?}", config);

    if let Err(err) =
        simplelog::TermLogger::init(opt.log_level, config, simplelog::TerminalMode::Stderr)
    {
        eprintln!("can not initialize logger: {}", err);
        ::std::process::exit(1);
    }

    error!("test");

    info!("test");
}
Drakulix commented 5 years ago

Fix published as v0.7.4