Push some debugging down to the IRC object.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 26 Aug 2012 11:16:11 +0000 (07:16 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 26 Aug 2012 11:16:11 +0000 (07:16 -0400)
irclib.py
irker.py

index a274d311092f7aa96c88e5be4e93d1d11571fa09..8b90a00d799b628b43fe795760b3acd77c100391 100644 (file)
--- a/irclib.py
+++ b/irclib.py
@@ -173,8 +173,6 @@ class IRC(object):
 
         self.add_global_handler("ping", _ping_ponger, -42)
 
-        self.debug(1, "IRC object created")
-
     def server(self):
         """Creates and returns a ServerConnection object."""
 
@@ -353,8 +351,8 @@ class IRC(object):
 
     def debug(self, level, errmsg):
         """Display debugging information."""
-        #if self.debuglevel >= level:
-        sys.stderr.write("irclib[%d]: %s\n" % (self.debuglevel, errmsg))
+        if self.debuglevel >= level:
+            sys.stderr.write("irclib[%d]: %s\n" % (self.debuglevel, errmsg))
 
     def _remove_connection(self, connection):
         """[Internal]"""
@@ -446,6 +444,7 @@ class ServerConnection(Connection):
 
     def __init__(self, irclibobj):
         super(ServerConnection, self).__init__(irclibobj)
+        self.irclibobj = irclibobj
         self.connected = 0  # Not connected yet.
         self.socket = None
         self.ssl = None
@@ -495,6 +494,10 @@ class ServerConnection(Connection):
         self.password = password
         self.localaddress = localaddress
         self.localport = localport
+
+        self.irclibobj.debug(1, "connect(server=%s, port=%s, nick=%s)" \
+                             % (self.server, self.port, self.nickname))
+
         self.localhost = socket.gethostname()
         if ipv6:
             self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
index 91be186062115e28fdfe3b263c9dc6116221259d..67431a984456770cdaf7b185c61c2069bbca4a33 100755 (executable)
--- a/irker.py
+++ b/irker.py
@@ -40,7 +40,6 @@ class Session():
         self.channel = parsed.path.lstrip('/')
         self.port = int(port)
         self.server = self.irker.irc.server()
-        self.irker.debug(1, "connecting: server=%s port=%s name=%s" % (self.servername, self.port, self.name()))
         self.server.connect(self.servername, self.port, self.name())
         Session.count += 1
     def enqueue(self, message):