diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-12-01 16:08:12 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-12-01 16:08:12 +0000 |
commit | f3fd118a71ee2e82a2f5f6d1415700c15428538f (patch) | |
tree | e12b144fe9413e1e4ce185e91ead58e0d0cfff4d /lib/thandy | |
parent | 5cf4885e09fddfd0649bef62447517f802de8895 (diff) |
Make controller logging work better on python 2.4 (where the "extra" feature of logger.log does not exist.)
git-svn-id: file:///home/or/svnrepo/updater/trunk@17431 55e972cd-5a19-0410-ae62-a4d7a52db4cd
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)) |