From d58591ceba61f09bdd5ba275bc56e86401d1fd9b Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 2 Jul 2008 17:40:29 -0700 Subject: [PATCH] start using Foolscap's 'incident-logging' feature, which requires foolscap-0.2.9 --- _auto_deps.py | 2 +- src/allmydata/node.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/_auto_deps.py b/_auto_deps.py index 1f79272d..6c5b585a 100644 --- a/_auto_deps.py +++ b/_auto_deps.py @@ -1,5 +1,5 @@ install_requires=["zfec >= 1.1.0", - "foolscap >= 0.2.8", + "foolscap >= 0.2.9", "simplejson >= 1.4", # pycryptopp < 0.5 had a bug which, using a Microsoft diff --git a/src/allmydata/node.py b/src/allmydata/node.py index e9481b84..fa21bfbb 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -2,12 +2,13 @@ import datetime, os.path, re, types from base64 import b32decode, b32encode -from twisted.python import log +from twisted.python import log as tahoe_log from twisted.application import service from twisted.internet import defer, reactor from foolscap import Tub, eventual +import foolscap.logging.log from allmydata import get_package_versions_string -from allmydata.util import log as tahoe_log +from allmydata.util import log from allmydata.util import fileutil, iputil, observer, humanreadable from allmydata.util.assertutil import precondition @@ -174,12 +175,12 @@ class Node(service.MultiService): def _service_startup_failed(self, failure): self.log('_startService() failed') - log.err(failure) + tahoe_log.err(failure) print "Node._startService failed, aborting" print failure #reactor.stop() # for unknown reasons, reactor.stop() isn't working. [ ] TODO self.log('calling os.abort()') - log.msg('calling os.abort()') + tahoe_log.msg('calling os.abort()') print "calling os.abort()" os.abort() @@ -201,11 +202,11 @@ class Node(service.MultiService): def setup_logging(self): # we replace the formatTime() method of the log observer that twistd # set up for us, with a method that uses better timestamps. - for o in log.theLogPublisher.observers: + for o in tahoe_log.theLogPublisher.observers: # o might be a FileLogObserver's .emit method if type(o) is type(self.setup_logging): # bound method ob = o.im_self - if isinstance(ob, log.FileLogObserver): + if isinstance(ob, tahoe_log.FileLogObserver): newmeth = types.UnboundMethodType(formatTimeTahoeStyle, ob, ob.__class__) ob.formatTime = newmeth # TODO: twisted >2.5.0 offers maxRotatedFiles=50 @@ -215,9 +216,11 @@ class Node(service.MultiService): self.tub.setOption("log-gatherer-furlfile", os.path.join(self.basedir, "log_gatherer.furl")) self.tub.setOption("bridge-twisted-logs", True) + incident_dir = os.path.join(self.basedir, "logs", "incidents") + foolscap.logging.log.setLogDir(incident_dir) def log(self, *args, **kwargs): - return tahoe_log.msg(*args, **kwargs) + return log.msg(*args, **kwargs) def old_log(self, msg, src="", args=(), **kw): if src: @@ -230,8 +233,8 @@ class Node(service.MultiService): except TypeError, e: msg = "ERROR: output string '%s' contained invalid %% expansion, error: %s, args: %s\n" % (`msg`, e, `args`) msg = self.short_nodeid + ": " + humanreadable.hr(msg) - return log.callWithContext({"system":logsrc}, - tahoe_log.msg, msg, **kw) + return tahoe_log.callWithContext({"system":logsrc}, + tahoe_log.msg, msg, **kw) def _setup_tub(self, local_addresses): # we can't get a dynamically-assigned portnum until our Tub is -- 2.45.2