Increased default logging level to info unless RUST_LOG is set #369
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sets the
INFO
as the default logging level shown to stdout unlessRUST_LOG
env var is set.fixes https://github.com/azerupi/mdBook/issues/358
TLNR:
Discussion:
I'm not really happy with the effects of this PR. The output starts to be overly verbose.
The original suggestion to use pretty_env_logger was misplaced due to two problems:
LogBuilder::filter
so we cannot set the default levelWhile the first is trivially circumvented by using env_logger directly, the second is not solvable if we want to stick to env_logger or any of its derivatives as these are incompatible with portable colored printing (all of them take preformatted string while on windows you need to directly manipulate terminal and stdio to have colored output)
On the other hand other colored loggers don't support log triggering/filtering based on RUST_LOG which might be important for consistency.
Cargo uses term while ripgrep uses termcolor crate to achieve colors in a portable manner.
We could use one of these in our own logger (or a backend for one of the more advanced loggin frameworks like fern or log4rs) But it feels too involved and we would need to reimplement env_logger's env var parsing.
All of these approaches seam forced at best and now I can see why cargo is using split logging (1 standard log for library part and 2 direct printing with termcolor for direct printing to stdout of cargo binary messages)