Skip to content

Commit

Permalink
Added NullHandlers to all loggers to preven "No handler" messages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
James Nowell committed Jun 25, 2015
1 parent 640d150 commit aa0ccea
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'output_stream')

log = logging.getLogger('git.cmd')
log.addHandler(logging.NullHandler())

__all__ = ('Git', )

Expand Down
1 change: 1 addition & 0 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


log = logging.getLogger('git.config')
log.addHandler(logging.NullHandler())


class MetaParserBuilder(abc.ABCMeta):
Expand Down
1 change: 1 addition & 0 deletions git/objects/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import logging

log = logging.getLogger('git.objects.commit')
log.addHandler(logging.NullHandler())

__all__ = ('Commit', )

Expand Down
1 change: 1 addition & 0 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@


log = logging.getLogger('git.objects.submodule.base')
log.addHandler(logging.NullHandler())


class UpdateProgress(RemoteProgress):
Expand Down
1 change: 1 addition & 0 deletions git/objects/submodule/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
__all__ = ["RootModule", "RootUpdateProgress"]

log = logging.getLogger('git.objects.submodule.root')
log.addHandler(logging.NullHandler())


class RootUpdateProgress(UpdateProgress):
Expand Down

0 comments on commit aa0ccea

Please sign in to comment.