DEbug the debug code :-)
authorEric S. Raymond <esr@thyrsus.com>
Sun, 26 Aug 2012 10:40:38 +0000 (06:40 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 26 Aug 2012 10:40:38 +0000 (06:40 -0400)
irker.py

index bf4e0649a00667d657bdeadf47bf673cefcdfa74..28fe59a6b5f8a3438ebabb63fcf760ecc828b695 100755 (executable)
--- a/irker.py
+++ b/irker.py
@@ -67,8 +67,8 @@ class Session():
 class Irker:
     "Persistent IRC multiplexer."
     def __init__(self, debuglevel=0):
-        self.debuglevel = 0
-        self.irc = irclib.IRC()
+        self.debuglevel = debuglevel
+        self.irc = irclib.IRC(self.debuglevel-1)
         thread = threading.Thread(target=self.irc.process_forever)
         self.irc._thread = thread
         thread.daemon = True
@@ -79,8 +79,8 @@ class Irker:
         sys.stderr.write("irker: " + errmsg + "\n")
     def debug(self, level, errmsg):
         "Debugging information."
-        if level >= self.debuglevel:
-            sys.stderr.write("irker: " + errmsg + "\n")
+        if self.debuglevel >= level:
+            sys.stderr.write("irker[%d]: %s\n" % (self.debuglevel, errmsg))
     def run(self, ifp, await=True):
         "Accept JSON relay requests from specified stream."
         while True: