From aa0ccead680443b07fd675f8b906758907bdb415 Mon Sep 17 00:00:00 2001 From: James Nowell Date: Thu, 25 Jun 2015 09:24:40 -0400 Subject: [PATCH] Added NullHandlers to all loggers to preven "No handler" messages 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. --- git/cmd.py | 1 + git/config.py | 1 + git/objects/commit.py | 1 + git/objects/submodule/base.py | 1 + git/objects/submodule/root.py | 1 + 5 files changed, 5 insertions(+) diff --git a/git/cmd.py b/git/cmd.py index 87e482d82..c0eeec0a5 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -44,6 +44,7 @@ 'output_stream') log = logging.getLogger('git.cmd') +log.addHandler(logging.NullHandler()) __all__ = ('Git', ) diff --git a/git/config.py b/git/config.py index a6a25c7bb..2d9adbdd9 100644 --- a/git/config.py +++ b/git/config.py @@ -32,6 +32,7 @@ log = logging.getLogger('git.config') +log.addHandler(logging.NullHandler()) class MetaParserBuilder(abc.ABCMeta): diff --git a/git/objects/commit.py b/git/objects/commit.py index ac381cd93..d301e3014 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -34,6 +34,7 @@ import logging log = logging.getLogger('git.objects.commit') +log.addHandler(logging.NullHandler()) __all__ = ('Commit', ) diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index f9b0b6ad6..30201e090 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -43,6 +43,7 @@ log = logging.getLogger('git.objects.submodule.base') +log.addHandler(logging.NullHandler()) class UpdateProgress(RemoteProgress): diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index 1c863f6fb..4fe856c2c 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -13,6 +13,7 @@ __all__ = ["RootModule", "RootUpdateProgress"] log = logging.getLogger('git.objects.submodule.root') +log.addHandler(logging.NullHandler()) class RootUpdateProgress(UpdateProgress):