From b69a5928718c8236a32d4a6eaec600a01d5fcd99 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Tue, 22 May 2012 14:03:32 +0530 Subject: geo-rep / gsyncd: sanitize error log of external commands If a command invoked by gsyncd fails, gsyncd makes a log of what comes out on its stderr. So far the log indeterministically broke lines at random places. Now put some effort into reconstructing original lines and having a faithful log. BUG: 764678 Change-Id: I16fcc75d3e0f624c10c71d9b37c937ca677087cc Signed-off-by: Csaba Henk Reviewed-on: http://review.gluster.com/3561 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/features/marker/utils/syncdaemon/resource.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py index 7e62fd48c..b9c757b60 100644 --- a/xlators/features/marker/utils/syncdaemon/resource.py +++ b/xlators/features/marker/utils/syncdaemon/resource.py @@ -188,9 +188,17 @@ class Popen(subprocess.Popen): filling = ", saying:" logging.error("""command "%s" returned with %s%s""" % \ (" ".join(self.args), repr(self.returncode), filling)) + lp = '' + def logerr(l): + logging.error(self.args[0] + "> " + l) for l in self.elines: - for ll in l.rstrip().split("\n"): - logging.error(self.args[0] + "> " + ll.rstrip()) + ls = l.split('\n') + ls[0] = lp + ls[0] + lp = ls.pop() + for ll in ls: + logerr(ll) + if lp: + logerr(lp) def errfail(self): """fail nicely if child did not terminate with success""" -- cgit