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

pattern encoder: Set trace to default color, reset formatting after #186

Merged
merged 4 commits into from
Dec 16, 2020

Conversation

judemille
Copy link
Contributor

Fixes #184, makes text readable no matter the color scheme.

@@ -584,14 +584,16 @@ impl FormattedChunk {
}
Level::Warn => w.set_style(Style::new().text(Color::Yellow))?,
Level::Info => w.set_style(Style::new().text(Color::Green))?,
Level::Trace => w.set_style(Style::new().text(Color::Black).intense(true))?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could probably remove the .intense or the branch altogether I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I'd like to keep the intense so it's more clear it's a logging level.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have us in parity with env_logger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding correctly, the color in env_logger causes issues, at least on my terminal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait nevermind, it has cyan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, in the source code of env_logger it does set the default color of trace to Cyan, but I just can't get it to print Cyan, but every other color is the same as what's printed. I distinctly remember seeing something very similar to (Color::Black).intense(true) when I originally made the PR and was the reason why I used intense here, but I just can't find it in their source code right now.

@ray-kast
Copy link

ray-kast commented Oct 5, 2020

I disagree with using Style::new().intense(true) as the trace format, as some terminals will also interpret this as "use a bold font" in addition to "use bright white." If the format pattern included {h({m})} or any other pattern that expands to a long string, this would result in a lot of bold, bright-white text on the terminal given the typical volume of trace log records. Something like Style::new().text(Color::Blue) would be much easier on the eyes, and still convey the same information.

@IceSentry
Copy link
Contributor

@Rookie1024 I'd rather trace have no specific color at this point until this is made configurable. I don't think going from no color but intense to blue is a solution to the problem, but it's a valid concern that intense might not be ideal for trace level

@ray-kast
Copy link

ray-kast commented Oct 5, 2020

@IceSentry Ah, that's fair. I was worried this was going to remain unconfigurable, which would have made this PR a nightmare for my current use case where I am actually using {h({m})} because I suck at reading :p

Level::Error | Level::Warn | Level::Info => w.set_style(&Style::new())?,
Level::Error | Level::Warn | Level::Info | Level::Trace => {
w.set_style(&Style::new())?
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we adding trace level here again?

@noyez noyez mentioned this pull request Oct 14, 2020
@estk
Copy link
Owner

estk commented Dec 16, 2020

@judemille we're so close! Any update on this?

@judemille
Copy link
Contributor Author

judemille commented Dec 16, 2020

I think someone just wanted to add the trace level? Not sure, just this is my best take on making what existed compatible.

E: Right, in that second statement, it's to clear the intense set earlier in the file.

@estk
Copy link
Owner

estk commented Dec 16, 2020

@judemille I think the only thing left is just using the colors in #190 so that it will match env_logger

@estk
Copy link
Owner

estk commented Dec 16, 2020

@judemille what envlogger sets:

        match level {
            Level::Trace => level_style.set_color(Color::Cyan),
            Level::Debug => level_style.set_color(Color::Blue),
            Level::Info => level_style.set_color(Color::Green),
            Level::Warn => level_style.set_color(Color::Yellow),
            Level::Error => level_style.set_color(Color::Red).set_bold(true),
        };

E: I think just fixing trace is good actually

@estk estk merged commit 36627ba into estk:devel Dec 16, 2020
estk added a commit that referenced this pull request Dec 16, 2020
* Expose errors as failure::Error (#138)

* Issue #129: Drop XML Config support (#137)

* Rename file feature (#147)

* Rename to config_parsing

* Add workflows for devel

* Update changelog

* Add an init function which takes a RawConfig (#150)

* Clippy

* Changelog, cleanup

* json macro

* qualify

* typo

* Remove unused dir from .gitignore

* Init raw on all platforms

* Remove log4rs::FormatError::XmlFeatureFlagRequired (#156)

* Expand env vars in the path for File and RollingFile appenders (#155)

* Reorganize config (#157)

* Reorganize config

* allow missing docs so tests run

* lint abatement

* some renames

* Use anyhow/thiserror (#159)

* Use anyhow/thiserror

* Change addtivity to additive to match the actual code (#163)

* Errors 1.0 (#160)

Co-authored-by: shmapdy <richard.meester@gmail.com>

* clippy

* Standard derives rebase (#175)

* Bump serde-value

* Alpha 1 version

* Update highlight colors to be the same as env_logger (#167)

* Custom err handler (#183)

* WIP custom err handling

* Compiling

* Add an  method to the public api

* re-enable Debug

* bump ver

* fix: init_raw_config forcing max_log_level to Info (#200)

Co-authored-by: braindead <braindeaded@protonmail.com>

* pattern encoder: Set trace to default color, reset formatting after (#186)

* pattern encoder: Set trace to default color, reset formatting after

* Fix formatting of last commit

* lol apparently rustfmt doesn't like commas? idk if this will work

* Set trace color to cyan

Co-authored-by: Richard M <gadunga@users.noreply.github.com>
Co-authored-by: shmapdy <richard.meester@gmail.com>
Co-authored-by: Charles Giguere <IceSentry@users.noreply.github.com>
Co-authored-by: 1c7718e7 <shirokovMartin@gmail.com>
Co-authored-by: braindead <braindeaded@protonmail.com>
Co-authored-by: Julia DeMille <8127111+judemille@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants