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

click_log only applies to the initial module's logger. #9

Closed
WhyNotHugo opened this issue Aug 27, 2017 · 6 comments
Closed

click_log only applies to the initial module's logger. #9

WhyNotHugo opened this issue Aug 27, 2017 · 6 comments

Comments

@WhyNotHugo
Copy link
Contributor

On an app with more than one logger, click_log will configure the logger for the initial module (where click_log.basic_config is called), but not other modules.

This results in click_log effectively having no effect on other modules.

A potential solution for this, would be to make basic_config take logger as an OPTIONAL parameter.
If logger == None, then configure logging (which basically means, override global defaults).

@untitaker
Copy link
Collaborator

click_log will configure the logger for the initial module (where click_log.basic_config is called), but not other modules.

basic_config takes a logger and configures it. If you call it with __name__ it will only configure the logger for the CLI module. Call it with "todoman".

@WhyNotHugo
Copy link
Contributor Author

That still won't activate logging for third party libraries though (which is in many cases desirable).

@untitaker
Copy link
Collaborator

untitaker commented Aug 29, 2017 via email

@simonvanderveldt
Copy link

simonvanderveldt commented Sep 14, 2017

Then pass the root logger instead

I had to do this for both click_log.basic_config("") as well as @click_log.simple_verbosity_option("").
I'm not sure this makes sense?

With the previous version none of this was necessary btw, which was the behaviour I was expecting. I'd prefer it to work the way it did, i.e. the logger is configured for all loggers.
If it's going to stay the way it is right now this should probably be documented, I'd expect more people to start asking this question.

@untitaker
Copy link
Collaborator

untitaker commented Sep 14, 2017 via email

@simonvanderveldt
Copy link

simonvanderveldt commented Sep 14, 2017

The behavior didn't change in that regard. You still pass a logger to
basic_config / init, the default is the root logger.

This is not the case for simple_verbosity_option since it doesn't come with a default assigned to logger, see

def simple_verbosity_option(logger, *names, **kwargs):

Sure, which part of the docs are you referring to?

Something like adding a title/header with contents for:

  • "Controlling the verbosity of your click-log using module". (Don't use this exact wording, it sucks :P)
  • "Controlling the verbosity of all modules used"

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

No branches or pull requests

3 participants