Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Add set_log_verbosity function #56

Open
vitiral opened this issue Feb 13, 2018 · 4 comments
Open

Add set_log_verbosity function #56

vitiral opened this issue Feb 13, 2018 · 4 comments

Comments

@vitiral
Copy link
Contributor

vitiral commented Feb 13, 2018

#51 adds a hidden set_log_verbosity function which is currently an implementation detail of the main! macro. However, I would like to break it out into a general enough function that could be used outside of main!.

This comment proposed the following API

fn set_log_verbosity(lowest: u64, levels: &[(&str, u64)])
  • lowest is the lowest log level, i.e. set to 1 to enable all warnings.
  • levels is a tuple containing the custom levels for specific crates.

This gives complete flexibility but is also very simple.

Discuss!

@nbigaouette
Copy link

Could the levels be enums and not integers? There was also discussion about using RUST_LOG in #46. How would that fit in?

@CAD97
Copy link
Contributor

CAD97 commented Feb 16, 2018

I think LoggerBuilder::from_env should be called at the start, such that an environment variable can be used for overrides. I mean, that's the reason to use env_logger, isn't it? But that seems orthogonal.

If we're designing an easy wrapper around "the logging implementation", we shouldn't be afraid to use log's terminology to talk about it. Therefore I think the following signature feels best currently (subject to bikeshed of course):

fn set_up_logger(
    default: ::log::LevelFilter,
    overrides: &[(&str, ::log::LevelFilter)],
) -> Result<()>

@killercup
Copy link
Owner

killercup commented Feb 16, 2018

I think LoggerBuilder::from_env should be called at the start

👍

If we're designing an easy wrapper around "the logging implementation"

FTR, originally, the function was about turning "number of -v flags given" into a LogLevel.

I'm still unsure of what kind of API to expose (cf. #51 (comment))

@vitiral
Copy link
Contributor Author

vitiral commented Feb 16, 2018 via email

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

No branches or pull requests

4 participants