From 176a34161fd325dbfd788148b860f6abe606d04d Mon Sep 17 00:00:00 2001 From: Greg Lange Date: Mon, 22 Jul 2013 22:09:40 +0000 Subject: [PATCH] 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 --- etc/object-server.conf-sample | 4 ++++ swift/obj/replicator.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/etc/object-server.conf-sample b/etc/object-server.conf-sample index 00fce516f6..714279c9bc 100644 --- a/etc/object-server.conf-sample +++ b/etc/object-server.conf-sample @@ -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!): diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py index b3ffa10f51..2f76057601 100644 --- a/swift/obj/replicator.py +++ b/swift/obj/replicator.py @@ -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)"),