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 all commits
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
13 changes: 13 additions & 0 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@
'RemoteProgress', 'CallableRemoteProgress', 'rmtree', 'unbare_repo',
'HIDE_WINDOWS_KNOWN_ERRORS')


try: # Python 2.7+
import logging.NullHandler
except ImportError:
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())

#: We need an easy way to see if Appveyor TCs start failing,
#: so the errors marked with this var are considered "acknowledged" ones, awaiting remedy,
Expand Down Expand Up @@ -384,6 +395,8 @@ def _parse_progress_line(self, line):
# handle
# Counting objects: 4, done.
# Compressing objects: 50% (1/2) \rCompressing objects: 100% (2/2) \rCompressing objects: 100% (2/2), done.
log.info(line)

self._cur_line = line
if len(self.error_lines) > 0 or self._cur_line.startswith(('error:', 'fatal:')):
self.error_lines.append(self._cur_line)
Expand Down