rust-cli / env_logger

A logging implementation for `log` which is configured via an environment variable.
https://docs.rs/env_logger
Apache License 2.0
782 stars 124 forks source link

Add `FilteredLog` utility to combine a `Filter` with a `Log`. #295

Closed de-vri-es closed 5 months ago

de-vri-es commented 6 months ago

This can be used by end-users that want to combine the filtering capabilities of env_logger with a different Log implementation.

In my case, I want to combine the filtering of env_logger with systemd-journal-logger. I could just do it myself where I need it, but this feels like something that could be useful to provide from env_logger already.

epage commented 6 months ago

193 is the issue for this. I lean towards the crate-splitting route, over publically exposing these details within this crate.

de-vri-es commented 6 months ago

The Filter type is already exposed though. It's true that you could pull in less dependencies if you only want the Filter type.

So.. if I make a PR to split Filter to a separate crate (env_logger_filter, env_log_filter, env_filter, bikeshed...) and re-export it from env_logger, would that be a good way forward?

And then would you be inclined to accept this utility to wrap an existing logger?

de-vri-es commented 6 months ago

Pushed a commit to split the filter module off to a separate crate. What do you think?

Or do you think it would be better to move it to a separate git repo?

epage commented 5 months ago

I've incorporated parts of this into #299 and #300