From bb698c1fa573ca9404f5f2f1d40636bf05f7277f Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 9 Jul 2008 10:41:13 +0000 Subject: [PATCH] Convert utils.py to the logging module The patch also logs all commands executed from RunCmd when we are at debug level. Reviewed-by: imsnah --- lib/utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/utils.py b/lib/utils.py index 731752821..5e4233a05 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -39,10 +39,10 @@ import itertools import select import fcntl import resource +import logging from cStringIO import StringIO -from ganeti import logger from ganeti import errors from ganeti import constants @@ -88,9 +88,9 @@ class RunResult(object): else: self.fail_reason = "unable to determine termination reason" - if debug and self.failed: - logger.Debug("Command '%s' failed (%s); output: %s" % - (self.cmd, self.fail_reason, self.output)) + if self.failed: + logging.debug("Command '%s' failed (%s); output: %s", + self.cmd, self.fail_reason, self.output) def _GetOutput(self): """Returns the combined stdout and stderr for easier usage. @@ -123,6 +123,7 @@ def RunCmd(cmd): else: strcmd = cmd shell = True + logging.debug("RunCmd '%s'", strcmd) env = os.environ.copy() env["LC_ALL"] = "C" poller = select.poll() @@ -258,8 +259,7 @@ def CheckDict(target, template, logname=None): target[k] = template[k] if missing and logname: - logger.Debug('%s missing keys %s' % - (logname, ', '.join(missing))) + logging.warning('%s missing keys %s', logname, ', '.join(missing)) def IsProcessAlive(pid): @@ -386,7 +386,7 @@ def ListVolumeGroups(): name, size = line.split() size = int(float(size)) except (IndexError, ValueError), err: - logger.Error("Invalid output from vgs (%s): %s" % (err, line)) + logging.error("Invalid output from vgs (%s): %s", err, line) continue retval[name] = size -- GitLab