env_logger icon indicating copy to clipboard operation
env_logger copied to clipboard

Hiding module path but displaying target

Open ClementNerma opened this issue 3 years ago • 3 comments

Hi!

I'm currently stuck at configuring the logger. By default, if I write the following code:

// module: example
error!("YOH");
error!(target: "a", "YOH");

It will display:

[2022-10-19T11:08:47Z INFO  onix_server] YOH
[2022-10-19T11:08:47Z INFO  a] YOH

What I'd like to see is:

[2022-10-19T11:08:47Z INFO  ] YOH
[2022-10-19T11:08:47Z INFO  a] YOH

Which means not displaying the module the log comes from, but displaying the custom target if any is provided.

How can I achieve that? I use .format_module_path(false) but it seemed to have no effect.

Thanks in advance for your help!

ClementNerma avatar Oct 19 '22 11:10 ClementNerma

I recommend trying another crate like pretty_env_logger since this one is practically not maintained. I'll keep this issue open though, in case somebody else wants to answer (but I don't expect anybody will).

jplatte avatar Oct 19 '22 11:10 jplatte

FYI this is now being passively maintained by WG-CLI.

If someone is willing to write up a proposal on the current behavior and new desired behavior for this, we would be willing to evaluate that before moving on to a PR.

epage avatar Nov 10 '22 03:11 epage

Is there any way to hide the module path?

mistgc avatar Aug 26 '23 01:08 mistgc