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

logging: callHandlers tests handler levels instead of logger levels? #45825

Closed
gidiavrahami mannequin opened this issue Nov 21, 2007 · 3 comments
Closed

logging: callHandlers tests handler levels instead of logger levels? #45825

gidiavrahami mannequin opened this issue Nov 21, 2007 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gidiavrahami
Copy link
Mannequin

gidiavrahami mannequin commented Nov 21, 2007

BPO 1484
Nosy @vsajip

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2007-11-22.15:30:08.738>
created_at = <Date 2007-11-21.22:41:17.149>
labels = ['invalid', 'type-bug', 'library']
title = 'logging: callHandlers tests handler levels instead of logger levels?'
updated_at = <Date 2014-04-14.10:37:32.130>
user = 'https://bugs.python.org/gidiavrahami'

bugs.python.org fields:

activity = <Date 2014-04-14.10:37:32.130>
actor = 'artur.ambroziak'
assignee = 'none'
closed = True
closed_date = <Date 2007-11-22.15:30:08.738>
closer = 'vinay.sajip'
components = ['Library (Lib)']
creation = <Date 2007-11-21.22:41:17.149>
creator = 'gidi_avrahami'
dependencies = []
files = []
hgrepos = []
issue_num = 1484
keywords = []
message_count = 3.0
messages = ['57741', '57762', '216070']
nosy_count = 3.0
nosy_names = ['vinay.sajip', 'gidi_avrahami', 'artur.ambroziak']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1484'
versions = ['Python 2.7']

@gidiavrahami
Copy link
Mannequin Author

gidiavrahami mannequin commented Nov 21, 2007

I am using the logging module with multiple loggers and the following
behavior seems incorrect to me:

I set the root logger's level to WARN and the foo.bar module's logger's
level to DEBUG, and the foo.bar logger should is writing to a file. So
basically, I want foo.bar to log itself in details behind the scenes
while the main console is quiet.

However, I still get all the sebug info printed to the console. When I
trace down the code, I see that callHandlers() is climbing up the logger
hierarchy, but it's comparing record.level to hdlr.level, not to
c.level. The handler levels, however, don't appear to be set normally
(i.e., after I do getLogger("foo.bar").setLevel, its handlers stay at
level NOTSET). As a result, callHandlers will call all the handlers
above the first one, no matter what the loggers level.

Is this intentional? If it is, how should I get the behavior that I
described above? (I could set propagate=False, but in fact if the rott
logger is DEBUG then I do want it to print the foo.bar messages)

@gidiavrahami gidiavrahami mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 21, 2007
@vsajip
Copy link
Member

vsajip commented Nov 22, 2007

The behaviour you describe is intentional. To achieve what you want, you
can either set levels on the handlers or use Filters on loggers and/or
handlers (if level-based filtering is not sufficient for your needs).

@vsajip vsajip closed this as completed Nov 22, 2007
@vsajip vsajip added the invalid label Nov 22, 2007
@arturambroziak
Copy link
Mannequin

arturambroziak mannequin commented Apr 14, 2014

So what is logger level for if it's not used on calling handlers?

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant