[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r23066: {arm} fix: incompatability with TorCtl's new logging implementatio (in arm/trunk: . src/interface src/util)
Author: atagar
Date: 2010-08-27 05:32:05 +0000 (Fri, 27 Aug 2010)
New Revision: 23066
Modified:
arm/trunk/arm
arm/trunk/src/interface/controller.py
arm/trunk/src/interface/logPanel.py
arm/trunk/src/util/torTools.py
Log:
fix: incompatability with TorCtl's new logging implementation, causing freezing on TorCtl events
fix: dropping NOTICE events unless requested
fix: changing /usr/bin starter to reflect arm's new install path
Modified: arm/trunk/arm
===================================================================
--- arm/trunk/arm 2010-08-26 20:10:59 UTC (rev 23065)
+++ arm/trunk/arm 2010-08-27 05:32:05 UTC (rev 23066)
@@ -1,7 +1,7 @@
#!/bin/sh
-if [ $0 = /usr/local/bin/arm ]
+if [ $0 = /usr/bin/arm ]
then
- arm_base=/usr/local/arm/
+ arm_base=/usr/arm/
else
arm_base=src/
fi
Modified: arm/trunk/src/interface/controller.py
===================================================================
--- arm/trunk/src/interface/controller.py 2010-08-26 20:10:59 UTC (rev 23065)
+++ arm/trunk/src/interface/controller.py 2010-08-27 05:32:05 UTC (rev 23066)
@@ -404,9 +404,11 @@
panels["log"].loggedEvents = loggedEvents # strips any that couldn't be set
# directs logged TorCtl events to log panel
- TorUtil.loglevel = "DEBUG"
- TorUtil.logfile = panels["log"]
+ #TorUtil.loglevel = "DEBUG"
+ #TorUtil.logfile = panels["log"]
+ torTools.getConn().addTorCtlListener(panels["log"].tor_ctl_event)
+
# tells revised panels to run as daemons
panels["header"].start()
Modified: arm/trunk/src/interface/logPanel.py
===================================================================
--- arm/trunk/src/interface/logPanel.py 2010-08-26 20:10:59 UTC (rev 23065)
+++ arm/trunk/src/interface/logPanel.py 2010-08-27 05:32:05 UTC (rev 23066)
@@ -215,7 +215,8 @@
if "BW" in self.loggedEvents: self.registerEvent("BW", "READ: %i, WRITTEN: %i" % (event.read, event.written), "cyan")
def msg_event(self, event):
- self.registerEvent(event.level, event.msg, RUNLEVEL_EVENT_COLOR[event.level])
+ if event.level in self.loggedEvents:
+ self.registerEvent(event.level, event.msg, RUNLEVEL_EVENT_COLOR[event.level])
def new_desc_event(self, event):
if "NEWDESC" in self.loggedEvents:
@@ -252,12 +253,15 @@
def monitor_event(self, level, msg):
# events provided by the arm monitor
- if "ARM_" + level in self.loggedEvents: self.registerEvent("ARM-%s" % level, msg, RUNLEVEL_EVENT_COLOR[level])
+ if "ARM_" + level in self.loggedEvents:
+ self.registerEvent("ARM-%s" % level, msg, RUNLEVEL_EVENT_COLOR[level])
def tor_ctl_event(self, level, msg):
# events provided by TorCtl
- if "TORCTL_" + level in self.loggedEvents: self.registerEvent("TORCTL-%s" % level, msg, RUNLEVEL_EVENT_COLOR[level])
+ if "TORCTL_" + level in self.loggedEvents:
+ self.registerEvent("TORCTL-%s" % level, msg, RUNLEVEL_EVENT_COLOR[level])
+ # TODO: deprecated (remove later)
def write(self, msg):
"""
Tracks TorCtl events. Ugly hack since TorCtl/TorUtil.py expects a file.
Modified: arm/trunk/src/util/torTools.py
===================================================================
--- arm/trunk/src/util/torTools.py 2010-08-26 20:10:59 UTC (rev 23065)
+++ arm/trunk/src/util/torTools.py 2010-08-27 05:32:05 UTC (rev 23066)
@@ -55,6 +55,9 @@
"NS": "information related to the consensus will grow stale",
"NEWCONSENSUS": "information related to the consensus will grow stale"}
+# provides int -> str mappings for torctl event runlevels
+TORCTL_RUNLEVELS = dict([(val, key) for (key, val) in TorUtil.loglevels.items()])
+
def loadConfig(config):
config.update(CONFIG)
@@ -156,8 +159,7 @@
self._cachedParam = dict([(arg, "") for arg in CACHE_ARGS])
# directs TorCtl to notify us of events
- TorUtil.loglevel = "DEBUG"
- TorUtil.logfile = self
+ TorUtil.logger = self
def init(self, conn=None):
"""
@@ -727,23 +729,18 @@
def unknown_event(self, event):
self._updateHeartbeat()
- def write(self, msg):
+ def log(self, level, msg, *args):
"""
- Tracks TorCtl events. Ugly hack since TorCtl/TorUtil.py expects a file.
+ Tracks TorCtl events. Ugly hack since TorCtl/TorUtil.py expects a
+ logging.Logger instance.
"""
- timestampStart, timestampEnd = msg.find("["), msg.find("]")
- level = msg[:timestampStart]
- msg = msg[timestampEnd + 2:].strip()
-
# notifies listeners of TorCtl events
- for callback in self.torctlListeners: callback(level, msg)
+ for callback in self.torctlListeners: callback(TORCTL_RUNLEVELS[level], msg)
# checks if TorCtl is providing a notice that control port is closed
if TOR_CTL_CLOSE_MSG in msg: self.close()
- def flush(self): pass
-
def _updateHeartbeat(self):
"""
Called on any event occurance to note the time it occured.