Make the length of a line logged configurable

Failed calls to rysnc can
  result in very long log lines.

These lines are
  mostly made up
of file paths and are
  not always useful.

This change will
  allow for reducing the
length of these
  lines logged if desired.

Change-Id: I9a28f19eadc07757da9d42b0d7be1ed82170d732
This commit is contained in:
Greg Lange 2013-07-22 22:09:40 +00:00
parent 8b378e7614
commit 176a34161f
2 changed files with 11 additions and 2 deletions

View File

@ -135,6 +135,10 @@ use = egg:swift#recon
#
# ring_check_interval = 15
# recon_cache_path = /var/cache/swift
#
# limits how long rsync error log lines are
# 0 means to log the entire line
# rsync_error_log_line_length = 0
[object-updater]
# You can override the default log routing for this app here (don't use set!):

View File

@ -81,6 +81,8 @@ class ObjectReplicator(Daemon):
self.headers = {
'Content-Length': '0',
'user-agent': 'obj-replicator %s' % os.getpid()}
self.rsync_error_log_line_length = \
int(conf.get('rsync_error_log_line_length', 0))
def _rsync(self, args):
"""
@ -112,8 +114,11 @@ class ObjectReplicator(Daemon):
else:
self.logger.error(result)
if ret_val:
self.logger.error(_('Bad rsync return code: %(ret)d <- %(args)s'),
{'args': str(args), 'ret': ret_val})
error_line = _('Bad rsync return code: %(ret)d <- %(args)s') % \
{'args': str(args), 'ret': ret_val}
if self.rsync_error_log_line_length:
error_line = error_line[:self.rsync_error_log_line_length]
self.logger.error(error_line)
elif results:
self.logger.info(
_("Successful rsync of %(src)s at %(dst)s (%(time).03f)"),