diff options
Diffstat (limited to 'git/objects')
-rw-r--r-- | git/objects/commit.py | 14 | ||||
-rw-r--r-- | git/objects/submodule/base.py | 12 | ||||
-rw-r--r-- | git/objects/submodule/root.py | 8 |
3 files changed, 20 insertions, 14 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py index 4a4a314c..9c733695 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -31,7 +31,9 @@ from time import ( altzone ) import os -import sys +import logging + +log = logging.getLogger('git.objects.commit') __all__ = ('Commit', ) @@ -473,16 +475,16 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): try: self.author.name = self.author.name.decode(self.encoding) except UnicodeDecodeError: - print >> sys.stderr, "Failed to decode author name '%s' using encoding %s" % ( - self.author.name, self.encoding) + log.error("Failed to decode author name '%s' using encoding %s", self.author.name, self.encoding, + exc_info=True) # END handle author's encoding # decode committer name try: self.committer.name = self.committer.name.decode(self.encoding) except UnicodeDecodeError: - print >> sys.stderr, "Failed to decode committer name '%s' using encoding %s" % ( - self.committer.name, self.encoding) + log.error("Failed to decode committer name '%s' using encoding %s", self.committer.name, self.encoding, + exc_info=True) # END handle author's encoding # a stream from our data simply gives us the plain message @@ -491,7 +493,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): try: self.message = self.message.decode(self.encoding) except UnicodeDecodeError: - print >> sys.stderr, "Failed to decode message '%s' using encoding %s" % (self.message, self.encoding) + log.error("Failed to decode message '%s' using encoding %s", self.message, self.encoding, exc_info=True) # END exception handling return self diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 6951fd63..d6f8982b 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -27,11 +27,14 @@ import stat import git import os -import sys +import logging __all__ = ["Submodule", "UpdateProgress"] +log = logging.getLogger('git.objects.submodule.base') + + class UpdateProgress(RemoteProgress): """Class providing detailed progress information to the caller who should @@ -408,7 +411,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch) mrepo.head.ref.set_tracking_branch(remote_branch) except IndexError: - print >> sys.stderr, "Warning: Failed to checkout tracking branch %s" % self.branch_path + log.warn("Failed to checkout tracking branch %s", self.branch_path) # END handle tracking branch # NOTE: Have to write the repo config file as well, otherwise @@ -437,11 +440,10 @@ class Submodule(util.IndexObject, Iterable, Traversable): binsha = rcommit.binsha hexsha = rcommit.hexsha else: - print >> sys.stderr, "%s a tracking branch was not set for local branch '%s'" % ( - msg_base, mrepo.head.ref) + log.error("%s a tracking branch was not set for local branch '%s'", msg_base, mrepo.head.ref) # END handle remote ref else: - print >> sys.stderr, "%s there was no local tracking branch" % msg_base + log.error("%s there was no local tracking branch", msg_base) # END handle detached head # END handle to_latest_revision option diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index 871cc21c..708749c7 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -5,10 +5,12 @@ from util import ( from git.exc import InvalidGitRepositoryError import git -import sys +import logging __all__ = ["RootModule", "RootUpdateProgress"] +log = logging.getLogger('git.objects.submodule.root') + class RootUpdateProgress(UpdateProgress): @@ -247,8 +249,8 @@ class RootModule(Submodule): # this way, it will be checked out in the next step # This will change the submodule relative to us, so # the user will be able to commit the change easily - print >> sys.stderr, "WARNING: Current sha %s was not contained in the tracking\ - branch at the new remote, setting it the the remote's tracking branch" % sm.hexsha + log.warn("Current sha %s was not contained in the tracking\ + branch at the new remote, setting it the the remote's tracking branch", sm.hexsha) sm.binsha = rref.commit.binsha # END reset binsha |