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

Consider not setting level on the colored handler #54

Open
gst opened this issue Apr 6, 2018 · 1 comment
Open

Consider not setting level on the colored handler #54

gst opened this issue Apr 6, 2018 · 1 comment

Comments

@gst
Copy link

gst commented Apr 6, 2018

Hi,

happy new user of coloredlogs for its out of the box nice feature.

please consider this use case:

In [1]: import coloredlogs

In [2]: import logging

In [3]: logger = logging.getLogger()

In [4]: coloredlogs.install()

In [5]: logger.setLevel(logging.DEBUG)

In [6]: logger.debug('foo')

In [7]: 

I find it a bit counter intuitive. Naively I'd have expected to see my "foo" debug call.

All would be good if coloredlogs wouldn't set the level on the actual handler but only on the root logger (or the explicitly passed one otherwise)..

wdyt ?

thx.

@guyskk
Copy link

guyskk commented Jul 5, 2018

I agree, I meet the same problem. I expect to see colored logs in all loggers, and allow loggers which level lower than root logger to emit messages.

My workaround:

coloredlogs.install(**colored_params)  # add colored handler to root logger
logging.getLogger().setLevel(logging.WARNING)  # reset root logger level
for h in logging.getLogger().handlers:
    h.setLevel(logging.NOTSET)  # reset colored handler level

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

2 participants