From a692e551c0080b8dfe71859486b37496f564c5bc Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 11 Oct 2011 16:31:05 +0200 Subject: [PATCH] use new logger Signed-off-by: Steven Armstrong --- lib/cdist/exec.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index b3b86a52..13cec499 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -25,14 +25,13 @@ import subprocess import cdist -log = logging.getLogger(__name__) - class Wrapper(object): def __init__(self, target_host, remote_exec, remote_copy): self.target_host = target_host self.remote_exec = remote_exec self.remote_copy = remote_copy + self.log = logging.getLogger(self.target_host) def remote_mkdir(self, directory): """Create directory on remote side""" @@ -58,15 +57,15 @@ class Wrapper(object): remote_prefix.append(self.target_host) args[0][:0] = remote_prefix - log.debug("Shell exec cmd: %s", args) + self.log.debug("Shell exec cmd: %s", args) if 'env' in kargs: - log.debug("Shell exec env: %s", kargs['env']) + self.log.debug("Shell exec env: %s", kargs['env']) try: subprocess.check_call(*args, **kargs) except subprocess.CalledProcessError: - log.error("Code that raised the error:\n") + self.log.error("Code that raised the error:\n") if remote: self.run_or_fail(["cat", script], remote=remote) @@ -89,13 +88,10 @@ class Wrapper(object): remote_prefix.append(self.target_host) args[0][:0] = remote_prefix - log.debug("Exec: " + " ".join(*args)) + self.log.debug("Exec: " + " ".join(*args)) try: subprocess.check_call(*args, **kargs) except subprocess.CalledProcessError: raise cdist.Error("Command failed: " + " ".join(*args)) except OSError as error: raise cdist.Error(" ".join(*args) + ": " + error.args[1]) - - -