Closed roman-khazanskii closed 6 months ago
Me too. Does anyone have any idea?
It would be better if you could set the time zone
Stumbled upon the same topic. Once you overwrite . format
you essentially use all the styling options and most of the builder calls won't do any good anymore. Same holds for pretty_env_logger
. The fact that the format: fmt::Builder
member of the Builder
is private makes all additional builder calls obsolete. It would be great to have access to format
within the closure?
I have this problem even without format()
. I have this code for tests:
let _ = env_logger::builder().filter_level(log::LevelFilter::Info).write_style(env_logger::WriteStyle::Always).is_test(true).try_init();
error!("Error!!");
No colour on Windows (haven't tried other platforms).
Ah actually in my case it was is_test(true)
that was causing the lack of colour. Without that I get colour. Not exactly sure why it would do that but never mind.
anstream
and allow WriteStyle
to control is_test
outputAt this point, users have all they need for this.
If you override our formatting, you have to provide the styling on your own. With 0.11, you can use any ANSI escape code formatting library you want and env_logger will automatically adapt it to the terminal you are using. We provide default_level_style to help you be consistent with the colors we use.
If I just do
env_logger::init();
then I see colored log messages, as expected, with different color for every log leve.However, if I use builder - everything is colorless, even though I call
.write_style(WriteStyle::Always)
:However, if I manually color all the text, like this:
red text is printed. Does it mean that if I want to use builder, I have to manually color all different levels?