]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
trying to introduce old style humanreadablied logs hopefully without breaking the...
authortahoe <tahoe@arnowaschk.de>
Sat, 11 Aug 2007 21:52:37 +0000 (14:52 -0700)
committertahoe <tahoe@arnowaschk.de>
Sat, 11 Aug 2007 21:52:37 +0000 (14:52 -0700)
src/allmydata/client.py
src/allmydata/node.py

index 55e364ad1b43b9842d719e6b67265ca5e39cba31..c2d74e46faf8a7ced30c3462614c8e4179eaa929 100644 (file)
@@ -37,6 +37,7 @@ class Client(node.Node, Referenceable):
 
     def __init__(self, basedir="."):
         node.Node.__init__(self, basedir)
+        self.logSource="Client"
         self.my_furl = None
         self.introducer_client = None
         self.init_storage()
index d3612b0d362f72ae0403385759d8e38f574fba5f..38c0dd715b93a313743c4934cbd41ca8d8114743 100644 (file)
@@ -7,10 +7,9 @@ from twisted.python import log
 from twisted.application import service
 from twisted.internet import defer, reactor
 from foolscap import Tub, eventual
-from allmydata.util import iputil, observer
+from allmydata.util import iputil, observer, humanreadable
 from allmydata.util.assertutil import precondition
 
-
 # Just to get their versions:
 import allmydata
 import zfec
@@ -52,6 +51,7 @@ class Node(service.MultiService):
         # our IP address and thus do tub.setLocation, and we can't register
         # any services with the Tub until after that point
         self.tub.setServiceParent(self)
+        self.logSource="Node"
 
         AUTHKEYSFILEBASE = "authorized_keys."
         for f in os.listdir(self.basedir):
@@ -117,8 +117,18 @@ class Node(service.MultiService):
         self.log("Node.shutdown")
         return self.stopService()
 
-    def log(self, msg):
-        log.msg(self.short_nodeid + ": " + msg)
+    def log(self, msg, src="", args=()):
+        if src:
+            logsrc = src
+        else:
+            logsrc=self.logSource
+        if args:
+            try:
+                msg = msg % tuple(map(humanreadable.hr, args))
+            except TypeError, e:
+                msg = "ERROR: output string '%s' contained invalid %% expansion, error: %s, args: %s\n" % (`msg`, e, `args`)
+        log.FileLogObserver.timeFormat="%y%m%d-%H:%M:%S"
+        log.callWithContext({"system":logsrc},log.msg,(self.short_nodeid + ": " + humanreadable.hr(msg)))
 
     def _setup_tub(self, local_addresses):
         # we can't get a dynamically-assigned portnum until our Tub is