Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space left after level #224

Open
steinemann opened this issue Dec 22, 2021 · 7 comments
Open

Space left after level #224

steinemann opened this issue Dec 22, 2021 · 7 comments
Labels

Comments

@steinemann
Copy link

The default message format will print:

[2021-12-22T08:22:29Z TRACE mymodule] <message>

When disable the target (module), there is an extra space before the ].

[2021-12-22T08:19:55Z INFO ] <message>
                          ^ here

Could this be fixed ?

@KonradHoeffner
Copy link

KonradHoeffner commented Aug 8, 2022

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] " with two spaces between them, so the fix should be simpler.
However when I copy that line from my post in Firefox Developer Edition 104, then the two spaces get reduced to one.

@epage
Copy link
Contributor

epage commented Nov 10, 2022

Without looking into this further, one question I have is if that is padding as INFO is one letter shorter than TRACE.

@epage epage added the question label Nov 10, 2022
@VorpalBlade
Copy link

VorpalBlade commented Nov 4, 2023

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?

@epage
Copy link
Contributor

epage commented Nov 6, 2023

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

@VorpalBlade
Copy link

@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?

@epage
Copy link
Contributor

epage commented Nov 6, 2023

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)

VorpalBlade added a commit to VorpalBlade/chezmoi_modify_manager that referenced this issue Nov 6, 2023
@epage
Copy link
Contributor

epage commented Jan 18, 2024

#298 will switch us to anstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants