Logging cleanup

Change-Id: Iebd3928ed0b483770d1c47b66e26eb8be249d720
This commit is contained in:
Ilya Shakhat
2016-07-06 10:52:13 +03:00
parent f7b268fd4c
commit 70c707ad62
5 changed files with 24 additions and 29 deletions

View File

@@ -393,7 +393,7 @@ def exception_handler():
except Exception as e:
if isinstance(e, exceptions.HTTPException):
raise # ignore Flask exceptions
LOG.exception(e)
LOG.error(e, exc_info=True)
flask.abort(404)
return exception_handler_decorated_function

View File

@@ -86,8 +86,8 @@ def get_vault():
flask.current_app.stackalytics_vault = vault
except Exception as e:
LOG.critical('Failed to initialize application: %s', e)
LOG.exception(e)
LOG.critical('Failed to initialize application: %s', e,
exc_info=True)
flask.abort(500)
if not getattr(flask.request, 'stackalytics_updated', None):

View File

@@ -131,7 +131,8 @@ class Gerrit(Rcs):
except RcsException:
self.error_count += 1
raise RcsException('Too many SSH errors, aborting')
raise RcsException('Too many SSH errors, aborting. Consider '
'increasing "gerrit_retry" value')
def _poll_reviews(self, project_organization, module, branch,
last_retrieval_time, status=None, grab_comments=False):

View File

@@ -174,13 +174,13 @@ class RecordProcessor(object):
lp_ids = set(u.get('launchpad_id') for u in user_profiles
if u.get('launchpad_id'))
if len(lp_ids) > 1:
LOG.info('Ambiguous launchpad ids: %s on profiles: %s',
lp_ids, user_profiles)
LOG.debug('Ambiguous launchpad ids: %s on profiles: %s',
lp_ids, user_profiles)
g_ids = set(u.get('gerrit_id') for u in user_profiles
if u.get('gerrit_id'))
if len(g_ids) > 1:
LOG.info('Ambiguous gerrit ids: %s on profiles: %s',
g_ids, user_profiles)
LOG.debug('Ambiguous gerrit ids: %s on profiles: %s',
g_ids, user_profiles)
merged_user = {} # merged user profile

View File

@@ -99,11 +99,11 @@ class Git(Vcs):
sh.git('reset', '--hard')
sh.git('checkout', 'origin/' + branch)
return True
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to checkout branch %(branch)s from repo '
'%(uri)s. Ignore it',
{'branch': branch, 'uri': self.repo['uri']})
LOG.exception(e)
{'branch': branch, 'uri': self.repo['uri']},
exc_info=True)
return False
def fetch(self):
@@ -114,10 +114,9 @@ class Git(Vcs):
try:
uri = str(
sh.git('config', '--get', 'remote.origin.url')).strip()
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to get config for git repo %s. Ignore it',
self.repo['uri'])
LOG.exception(e)
self.repo['uri'], exc_info=True)
return {}
if uri != self.repo['uri']:
@@ -131,18 +130,16 @@ class Git(Vcs):
try:
sh.git('clone', self.repo['uri'])
os.chdir(self.folder)
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to clone git repo %s. Ignore it',
self.repo['uri'])
LOG.exception(e)
self.repo['uri'], exc_info=True)
else:
os.chdir(self.folder)
try:
sh.git('fetch')
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to fetch git repo %s. Ignore it',
self.repo['uri'])
LOG.exception(e)
self.repo['uri'], exc_info=True)
return self._get_release_index()
@@ -173,10 +170,9 @@ class Git(Vcs):
_tty_out=False)
for commit_id in git_log_iterator:
self.release_index[commit_id.strip()] = release_name
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to get log of git repo %s. Ignore it',
self.repo['uri'])
LOG.exception(e)
self.repo['uri'], exc_info=True)
return self.release_index
def log(self, branch, head_commit_id):
@@ -194,10 +190,9 @@ class Git(Vcs):
output = sh.git('log', '--pretty=' + GIT_LOG_FORMAT, '--shortstat',
'-M', '--no-merges', commit_range, _tty_out=False,
_decode_errors='ignore', _encoding='utf8')
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to get log of git repo %s. Ignore it',
self.repo['uri'])
LOG.exception(e)
self.repo['uri'], exc_info=True)
return
for rec in re.finditer(GIT_LOG_PATTERN, six.text_type(output)):
@@ -286,10 +281,9 @@ class Git(Vcs):
try:
return str(sh.git('rev-parse', 'HEAD')).strip()
except sh.ErrorReturnCode as e:
except sh.ErrorReturnCode:
LOG.error('Unable to get HEAD for git repo %s. Ignore it',
self.repo['uri'])
LOG.exception(e)
self.repo['uri'], exc_info=True)
return None