Skip to content

Log lines for debugging #572

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

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed missing NullHanlder in Python 2.6
  • Loading branch information
expobrain committed Jan 10, 2017
commit f3693db53b90df2e6c609f9f8b2f9aaec2264e1b
8 changes: 8 additions & 0 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
'RemoteProgress', 'CallableRemoteProgress', 'rmtree', 'unbare_repo',
'HIDE_WINDOWS_KNOWN_ERRORS')


if not hasattr(logging, 'NullHandler'):
class NullHandler(logging.Handler):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what the NullHandler is used for. So far it was sufficient to obtain a logging using logging.getLogger('git.util') and assume parties interested in logging have set it up to contain/inherit handlers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I juts following the same pattern of enable logging like it is done in other part of GitPython as well (see git/cmd.py for example). The only difference is that unit tests under Python 2.6+ are failing because the logging package in 2.6 doesn't have the NullHandler thus this little piece of code.

def emit(self, record):
pass

logging.NullHandler = NullHandler

log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

Expand Down