diff options
Diffstat (limited to 'lib/thandy')
-rw-r--r-- | lib/thandy/ClientCLI.py | 14 | ||||
-rw-r--r-- | lib/thandy/repository.py | 1 | ||||
-rw-r--r-- | lib/thandy/util.py | 11 |
3 files changed, 13 insertions, 13 deletions
diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py index 839889b..14a149a 100644 --- a/lib/thandy/ClientCLI.py +++ b/lib/thandy/ClientCLI.py @@ -22,22 +22,14 @@ import thandy.encodeToXML json = thandy.util.importJSON() class ControlLogFormatter: - def _formatStr(self, s): - s = '"%s"' % re.sub(r'(["\\])', r'\\\1', s) - s = s.replace("\n", "\\n") - return s - def format(self, record): name = record.name if name == 'thandy-ctrl': - parts = [ record.msg ] - parts.extend( - "%s=%s"%(k, self._formatStr(v)) - for k,v in sorted(getattr(record, 'cmd_args', {}).iteritems())) - return " ".join(parts) + return record.getMessage() else: m = record.getMessage() - return "%s msg=%s"%(record.levelname, self._formatStr(m)) + return "%s msg=%s"%(record.levelname, + thandy.util.formatLogString(m)) def formatException(self, exc_info): return repr(traceback.print_exception()) diff --git a/lib/thandy/repository.py b/lib/thandy/repository.py index e5d94ff..3dc2864 100644 --- a/lib/thandy/repository.py +++ b/lib/thandy/repository.py @@ -321,7 +321,6 @@ class LocalRepository: try: f.load() except OSError, e: - print "need", f.getPath() logging.info("Couldn't load %s: %s. Must fetch it.", f.getPath(), e) need.add(f.getRelativePath()) diff --git a/lib/thandy/util.py b/lib/thandy/util.py index 2a76f54..e9db10a 100644 --- a/lib/thandy/util.py +++ b/lib/thandy/util.py @@ -2,6 +2,7 @@ import logging import os +import re import sys import tempfile import random @@ -198,7 +199,15 @@ def getRegistryValue(keyname): _controlLog = logging.getLogger("thandy-ctrl") +def formatLogString(s): + s = '"%s"' % re.sub(r'(["\\])', r'\\\1', s) + s = s.replace("\n", "\\n") + return s + def logCtrl(key, **args): """DOCDOC""" - _controlLog.log(logging.INFO, key, extra={'cmd_args':args}) + parts = [ key ] + parts.extend( + "%s=%s"%(k, formatLogString(v)) for k,v in sorted(args.iteritems())) + _controlLog.log(logging.INFO, " ".join(parts)) |