From: tahoe Date: Sat, 11 Aug 2007 21:52:37 +0000 (-0700) Subject: trying to introduce old style humanreadablied logs hopefully without breaking the... X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/COPYING.TGPPL.html?a=commitdiff_plain;h=f49194cb5e9ecd07efc16da88ecfbb107d31c40c;p=tahoe-lafs%2Ftahoe-lafs.git trying to introduce old style humanreadablied logs hopefully without breaking the existing ones --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 55e364ad..c2d74e46 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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() diff --git a/src/allmydata/node.py b/src/allmydata/node.py index d3612b0d..38c0dd71 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -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