Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
fixing a wrong logging message
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Groszer committed Jan 24, 2010
1 parent d5c3218 commit 8063ba9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/zc/ngi/async-udp.test
Expand Up @@ -8,16 +8,29 @@ async UDP support
... addr = '127.0.0.1'
... else:
... addr = ''
>>> addrText = repr((addr, 9644))


>>> zc.ngi.async.udp((addr, 9644), 'test')

>>> def handler(addr, message):
... print message

>>> import zope.testing.loggingsupport, logging
>>> loghandler = zope.testing.loggingsupport.InstalledHandler(
... None, level=logging.INFO)

>>> listener = zc.ngi.async.udp_listener((addr, 9644), handler)
>>> time.sleep(0.1)

>>> logcontent = str(loghandler)
>>> print logcontent # doctest: +ELLIPSIS
zc.ngi.async.udpserver INFO
listening on udp ('...', 9644)

>>> addrText in logcontent
True

>>> zc.ngi.async.udp((addr, 9644), 'test'); time.sleep(0.1)
test

Expand Down
4 changes: 2 additions & 2 deletions src/zc/ngi/async.py
Expand Up @@ -368,7 +368,7 @@ def __init__(self, addr, handler):
try:
if not is_win32:
self.set_reuse_addr()
self.logger.info("listening on %r", self.addr)
self.logger.info("listening on %r", addr)
self.bind(addr)
self.listen(255)
except socket.error:
Expand Down Expand Up @@ -441,7 +441,7 @@ def __init__(self, addr, handler, buffer_size=4096):
self.create_socket(family, socket.SOCK_DGRAM)
if not is_win32:
self.set_reuse_addr()
self.logger.info("listening on udp %r", self.addr)
self.logger.info("listening on udp %r", addr)
self.bind(addr)
except socket.error:
self.close()
Expand Down
33 changes: 33 additions & 0 deletions src/zc/ngi/async.txt
Expand Up @@ -182,3 +182,36 @@ we'll use the blocking interface:

The server log was printed. Note that we see the Error that we
requested above.

Check logging
=============

>>> import sys
>>> import time

>>> if sys.platform == 'win32':
... addr = '127.0.0.1'
... else:
... addr = ''
>>> addrText = repr((addr, 9644))


>>> def handler(addr, message):
... print message

>>> loghandler = zope.testing.loggingsupport.InstalledHandler(
... None, level=logging.INFO)

>>> listener = zc.ngi.async.listener((addr, 9644), handler)
>>> time.sleep(0.1)

>>> logcontent = str(loghandler)
>>> print logcontent # doctest: +ELLIPSIS
zc.ngi.async.server INFO
listening on ('...', 9644)

>>> addrText in logcontent
True

>>> listener.close()
>>> time.sleep(0.1)

0 comments on commit 8063ba9

Please sign in to comment.