borntyping / rust-simple_logger

A rust logger that prints all messages with a readable output format.
https://crates.io/crates/simple_logger
MIT License
221 stars 48 forks source link

`SimpleLogger::env` doesn't (fully) simulate `env_logger` #75

Closed d4h0 closed 10 months ago

d4h0 commented 1 year ago

The docs of SimpleLogger::env say "Simulates env_logger behavior", but this doesn't seem to be true.

The docs of env_logger mention "Logging is controlled via the RUST_LOG environment variable. The value of this environment variable is a comma-separated list of logging directives.", but comma-seperated logging directives are not supported in simple_logger:

    pub fn env(mut self) -> SimpleLogger {
        self.default_level = std::env::var("RUST_LOG")
            .ok()
            .as_deref()
            .map(log::LevelFilter::from_str)
            .and_then(Result::ok)
            .unwrap_or(self.default_level);

        self
    }

PS: Thanks for creating simple_logger. I like it quite a lot, and use it for all projects for which the tracing crate would be over-kill.

borntyping commented 1 year ago

A PR to update this would be welcome - only the RUST_LOG=info style is supported. (There are no plans to add the same filtering capabilities as env_logger provides.)

userffx commented 10 months ago

SimpleLogger::with_module_level already exists, adding support for RUST_LOG based filtering seems trivial

why is it not planned ?

borntyping commented 10 months ago

I added a notice to the project recently that covers this: https://github.com/borntyping/rust-simple_logger#project-status

In short - no features have been planned for this library for the better part of a decade. I keep up with bugfixes and merge contributed features that fit the project's goal of being simple, but I'm not interested in doing much more than that as I don't use the project myself.

If there's truely a trivial implementation for this, I'd welcome a pull request :)

userffx commented 10 months ago

i don't know if the code is simple enough but i created #89 anyway