Open steinemann opened 2 years ago
Are you sure that there is only one space between TRACE and mymodule?
For me, env_logger 0.0.9 prints "[2021-12-22T08:22:29Z TRACE mymodule]
Without looking into this further, one question I have is if that is padding as INFO is one letter shorter than TRACE.
I ran into this today:
let mut builder = Builder::from_env(Env::default().default_filter_or("warn"));
builder.format_timestamp(None);
builder.format_target(false);
//builder.format(|buf, record| {
// writeln!(buf, "[{}] {}", record.level(), record.args())
//});
builder.init();
Without the commented out code, I get the extra space too. The custom format would fix it for me, except I miss out on colours. I could probably add them back myself, but I'm not sure how to do so in a cross platform way that also works with redirect to file (non-terminal output) etc.
So my question is: How do I get rid of the space but keep the default auto-colour support for the log level?
There are ways to doing styling in a cross-platform way though I want to replace this with anstream
so you can just put in ANSI escape code styled text though working through our MSRV policy is the main limitation
@epage is there a way for me as a user to use anstream today with env_logger (MSRV is not an issue for me), or does it require access to internals making it impossible?
You might be able to get it to work by setting it to Target::Pipe
but I've not tested it for problems you may run into (locking, pipe bugs, etc)
anstream
The default message format will print:
When disable the target (module), there is an extra space before the
]
.Could this be fixed ?