Added NullHandlers to all loggers to prevent "No handler" messages by jamescnowell · Pull Request #300 · gitpython-developers/GitPython (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation4 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
When the code is run without setting up loggers, the loggers have no
handlers for the emitted messages. The logging module displays:No handlers could be found for logger "git.cmd"
on the
console. By adding a NullHandler (a no-op) the message disappears,
and doesn't affect logging when other handlers are configured.
When the code is run without setting up loggers, the loggers have no
handlers for the emitted messages. The logging module displays:
No handlers could be found for logger "git.cmd"
on the
console. By adding a NullHandler (a no-op) the message disappears,
and doesn't affect logging when other handlers are configured.
I'm not able to reproduce the error on my machine in Python 2.7. Also on the CI build, 'FOO' is totally in the exception. I'm not really sure what's supposed to be going on:
GitCommandError: 'Error when fetching: fatal: protocol error: bad line length character: FOO' returned with exit code 2
Thanks a for your contribution!
I took the liberty to add the required NullHandler implementation myself. Besides, you are right, the Foo
test is entirely unrelated to this PR, and needs additional attention.
You can watch the development stream on youtube.
GitPython #10 [PR 300 - add logging Null handlers]
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull request
The NullHandler class in git.util was added when merging gitpython-developers#300, to allow a noop handler to be used on Python 2.6, since the standard library logging.NullHandler class was added in Python 2.7.
When introduced in d1a9a23, the git.util.NullHandler class was also patched into the logging module, but that has no longer been done since 2fced2e (gitpython-developers#979), nor does GitPython make other use of it.
This also changes the parameter type annotation on the emit method
from object
to logging.LogRecord
, which is the expeced type.
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull request
This stops adding NullHandler
instances to GitPython's loggers.
As noted in gitpython-developers#1806, when they were added in gitpython-developers#300 this prevented
errors when GitPython logged messages and logging was not enabled,
but since Python 3.2 there is a logger of last resort providing a
nicer default behavior of showing the messages. (They are still
shown with better formatting if logging is configured, even if
just done with logging.basicConfig(), so applications should still
typically configure logging.)
2 participants