From 7a3c6f202449c4d4f8bd2bf0e4c97e22c95d5fdc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 18 Sep 2017 13:17:38 +0200 Subject: [PATCH] Add command to stdout/stderr log. --- cdist/exec/local.py | 4 ++-- cdist/exec/remote.py | 4 ++-- cdist/exec/util.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 575950c1..eec79399 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -254,8 +254,8 @@ class Local(object): output = None if do_save_output: - util.log_std_fd(self.log, stderr, 'Local stderr') - util.log_std_fd(self.log, stdout, 'Local stdout') + util.log_std_fd(self.log, command, stderr, 'Local stderr') + util.log_std_fd(self.log, command, stdout, 'Local stdout') return output except subprocess.CalledProcessError as e: diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 2331d3b2..8fcd0981 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -335,8 +335,8 @@ class Remote(object): stderr=stderr) output = None - util.log_std_fd(self.log, stderr, 'Remote stderr') - util.log_std_fd(self.log, stdout, 'Remote stdout') + util.log_std_fd(self.log, command, stderr, 'Remote stderr') + util.log_std_fd(self.log, command, stdout, 'Remote stdout') return output except subprocess.CalledProcessError as e: diff --git a/cdist/exec/util.py b/cdist/exec/util.py index 3d484013..2f2aa38c 100644 --- a/cdist/exec/util.py +++ b/cdist/exec/util.py @@ -169,8 +169,8 @@ def get_std_fd(base_path, name): return stdfd -def log_std_fd(log, stdfd, prefix): +def log_std_fd(log, command, stdfd, prefix): if stdfd is not None and stdfd != subprocess.DEVNULL: stdfd.seek(0, 0) - log.trace("{}: {}".format( - prefix, stdfd.read().decode())) + log.trace("Command: {}; {}: {}".format( + command, prefix, stdfd.read().decode()))