@@ -234,22 +234,23 @@ def cmd(self, command, *params):
234234 else :
235235 self .send (command )
236236
237- def send (self , line ):
237+ def send (self , line , log = True ):
238238 """
239239 Sends a raw IRC line
240240 :type line: str
241+ :type log: bool
241242 """
242243 if not self ._connected :
243244 raise ValueError ("Client must be connected to irc server to use send" )
244- self .loop .call_soon_threadsafe (self ._send , line )
245+ self .loop .call_soon_threadsafe (self ._send , line , log )
245246
246- def _send (self , line ):
247+ def _send (self , line , log = True ):
247248 """
248249 Sends a raw IRC line unchecked. Doesn't do connected check, and is *not* threadsafe
249250 :type line: str
251+ :type log: bool
250252 """
251- logger .info ("[{}] >> {}" .format (self .name , line ))
252- async_util .wrap_future (self ._protocol .send (line ), loop = self .loop )
253+ async_util .wrap_future (self ._protocol .send (line , log = log ), loop = self .loop )
253254
254255 @property
255256 def connected (self ):
@@ -316,7 +317,7 @@ def eof_received(self):
316317 return True
317318
318319 @asyncio .coroutine
319- def send (self , line ):
320+ def send (self , line , log = True ):
320321 # make sure we are connected before sending
321322 if not self ._connected :
322323 yield from self ._connected_future
@@ -352,6 +353,9 @@ def send(self, line):
352353 # the line must be encoded before we send it, one of the sieves didn't encode it, fall back to the default
353354 line = line .encode ("utf-8" , "replace" )
354355
356+ if log :
357+ logger .info ("[{}|out] >> {!r}" .format (self .conn .name , line ))
358+
355359 self ._transport .write (line )
356360
357361 def data_received (self , data ):
@@ -376,7 +380,7 @@ def data_received(self, data):
376380 # Reply to pings immediately
377381
378382 if command == "PING" :
379- async_util .wrap_future (self .send ("PONG " + command_params [- 1 ]), loop = self .loop )
383+ async_util .wrap_future (self .conn . send ("PONG " + command_params [- 1 ], log = False ), loop = self .loop )
380384
381385 # Parse the command and params
382386
0 commit comments