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

Only set log level for the root logger #434

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

hashhar
Copy link
Member

@hashhar hashhar commented Dec 22, 2023

Description

Before this change we called setLevel on each logger with level set to INFO. This meant that it was not possible to change log level for all child modules by doing something like
logging.getLogger('trino').setLevel(logging.DEBUG) because the child loggers had explicit levels set already. It instead required us to change log levels for each module (trino.client, trino.dbapi, trino.auth etc.) separately.

After this change only the root logger trino has a default level set. Other child loggers inherit from it. So now the default log level for all modules can be changed by doing
logging.getLogger('trino').setLevel(logging.DEBUG) for example.

Non-technical explanation

Make it easy to configure log level for all modules at once.

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text:

* Make it possible to configure log level for all modules via the root logger. ({issue}`424`)

Fixes #424

@hashhar
Copy link
Member Author

hashhar commented Dec 22, 2023

FYI @guerremdq

@hashhar hashhar force-pushed the hashhar/default-logger-improvement branch from 3b1eb3d to 7c09190 Compare December 22, 2023 09:23
Before this change we called `setLevel` on each logger with level set to
INFO. This meant that it was not possible to change log level for all
child modules by doing something like
`logging.getLogger('trino').setLevel(logging.DEBUG)` because the child
loggers had explicit levels set already. It instead required us to
change log levels for each module (`trino.client`, `trino.dbapi`,
`trino.auth` etc.) separately.

After this change only the root logger `trino` has a default level set.
Other child loggers inherit from it. So now the default log level for
all modules can be changed by doing
`logging.getLogger('trino').setLevel(logging.DEBUG)` for example.
@hashhar hashhar force-pushed the hashhar/default-logger-improvement branch from 7c09190 to 57074aa Compare December 22, 2023 09:32
@hashhar hashhar requested a review from ebyhr December 22, 2023 11:39
@hashhar hashhar merged commit 2a60ac9 into trinodb:master Dec 27, 2023
12 checks passed
@hashhar hashhar deleted the hashhar/default-logger-improvement branch December 27, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants