Initialize logger as a child of the Kivy's one #643
Merged
+6
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Preface
Kivy's logging has been recently improved via:
.. and more minor fixes + tests
When Kivy is in
KIVY_LOG_MODE=KIVY
(which is the default), the root logger level is set tologging.root.setLevel(logging.NOTSET)
, leaving the sub-loggers (and the Kivy logger) the ability to be the limiting factor.With the root logger set to
NOTSET
,pyjnius
started to send debug messages, even if the Kivy logger is set to silencedebug
messages.This is something expected for third-party libraries and
KIVY_LOG_MODE=MIXED
should be used instead, as explained here: https://kivy.org/doc/master/api-kivy.logger.html#mixed-mode.Considerations
pyjnius
is usable even outside of a Kivy project, but is still part of the Kivy ecosystem, and IMHO should log as Kivy does.By using a child logger of the Kivy main logger, if the Kivy logger is set to hide
debug
messages, also the log messages frompyjnius
will be filtered.From https://docs.python.org/3/library/logging.html#logging.Logger.setLevel:
Nothing changes when
pyjnius
is used in a non-kivy project (except that the logger name now have thekivy
prefix).👉 In order to make it fully compatible with the Kivy logger,
pyjnius
will also need to follow thecolon
separation logic, and will be nice to have an option to "mute" thepyjnius
logger, directly from the Kivy configuration. (I'm scheduling it for Kivy 2.2.0)FYI:
Everything started from issue: kivy/python-for-android#2704