summaryrefslogtreecommitdiff
path: root/lib/thandy/util.py
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-12-01 16:08:12 +0000
committerNick Mathewson <nickm@torproject.org>2008-12-01 16:08:12 +0000
commitf3fd118a71ee2e82a2f5f6d1415700c15428538f (patch)
treee12b144fe9413e1e4ce185e91ead58e0d0cfff4d /lib/thandy/util.py
parent5cf4885e09fddfd0649bef62447517f802de8895 (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/util.py')
-rw-r--r--lib/thandy/util.py11
1 files changed, 10 insertions, 1 deletions
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))