summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-10-17 22:39:45 (GMT)
committerGuido van Rossum <guido@dropbox.com>2013-10-17 22:39:45 (GMT)
commitfc29e0f37e8a5928c3ef38ce7e02c64984d1b5bc (patch)
tree9c111dea008d9eec467e63d76d59502c2f5128a3 /Lib/asyncio
parentb795aa8547b5a615d715fedc6a6267b7e8811d94 (diff)
downloadcpython-fc29e0f37e8a5928c3ef38ce7e02c64984d1b5bc.zip
cpython-fc29e0f37e8a5928c3ef38ce7e02c64984d1b5bc.tar.gz
cpython-fc29e0f37e8a5928c3ef38ce7e02c64984d1b5bc.tar.bz2
Rename the logger to plain "logger".
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py4
-rw-r--r--Lib/asyncio/events.py6
-rw-r--r--Lib/asyncio/futures.py6
-rw-r--r--Lib/asyncio/log.py3
-rw-r--r--Lib/asyncio/proactor_events.py10
-rw-r--r--Lib/asyncio/selector_events.py14
-rw-r--r--Lib/asyncio/tasks.py6
-rw-r--r--Lib/asyncio/unix_events.py16
-rw-r--r--Lib/asyncio/windows_events.py6
9 files changed, 36 insertions, 35 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 32457eb..5f1bff7 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -27,7 +27,7 @@ import sys
from . import events
from . import futures
from . import tasks
-from .log import asyncio_log
+from .log import logger
__all__ = ['BaseEventLoop', 'Server']
@@ -580,7 +580,7 @@ class BaseEventLoop(events.AbstractEventLoop):
level = logging.INFO
else:
level = logging.DEBUG
- asyncio_log.log(level, 'poll%s took %.3f seconds', argstr, t1-t0)
+ logger.log(level, 'poll%s took %.3f seconds', argstr, t1-t0)
self._process_events(event_list)
# Handle 'later' callbacks that are ready.
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index 9724615..6ca5668 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -12,7 +12,7 @@ import sys
import threading
import socket
-from .log import asyncio_log
+from .log import logger
class Handle:
@@ -36,8 +36,8 @@ class Handle:
try:
self._callback(*self._args)
except Exception:
- asyncio_log.exception('Exception in callback %s %r',
- self._callback, self._args)
+ logger.exception('Exception in callback %s %r',
+ self._callback, self._args)
self = None # Needed to break cycles when an exception occurs.
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
index 99a043b..db27838 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -10,7 +10,7 @@ import logging
import traceback
from . import events
-from .log import asyncio_log
+from .log import logger
# States for Future.
_PENDING = 'PENDING'
@@ -99,8 +99,8 @@ class _TracebackLogger:
def __del__(self):
if self.tb:
- asyncio_log.error('Future/Task exception was never retrieved:\n%s',
- ''.join(self.tb))
+ logger.error('Future/Task exception was never retrieved:\n%s',
+ ''.join(self.tb))
class Future:
diff --git a/Lib/asyncio/log.py b/Lib/asyncio/log.py
index 54dc784..23a7074 100644
--- a/Lib/asyncio/log.py
+++ b/Lib/asyncio/log.py
@@ -3,4 +3,5 @@
import logging
-asyncio_log = logging.getLogger("asyncio")
+# Name the logger after the package.
+logger = logging.getLogger(__package__)
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index 348de03..c1347b7 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -10,7 +10,7 @@ from . import base_events
from . import constants
from . import futures
from . import transports
-from .log import asyncio_log
+from .log import logger
class _ProactorBasePipeTransport(transports.BaseTransport):
@@ -50,7 +50,7 @@ class _ProactorBasePipeTransport(transports.BaseTransport):
self._read_fut.cancel()
def _fatal_error(self, exc):
- asyncio_log.exception('Fatal error for %s', self)
+ logger.exception('Fatal error for %s', self)
self._force_close(exc)
def _force_close(self, exc):
@@ -164,7 +164,7 @@ class _ProactorWritePipeTransport(_ProactorBasePipeTransport,
if self._conn_lost:
if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
- asyncio_log.warning('socket.send() raised exception.')
+ logger.warning('socket.send() raised exception.')
self._conn_lost += 1
return
self._buffer.append(data)
@@ -246,7 +246,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
def __init__(self, proactor):
super().__init__()
- asyncio_log.debug('Using proactor: %s', proactor.__class__.__name__)
+ logger.debug('Using proactor: %s', proactor.__class__.__name__)
self._proactor = proactor
self._selector = proactor # convenient alias
proactor.set_loop(self)
@@ -335,7 +335,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
f = self._proactor.accept(sock)
except OSError:
if sock.fileno() != -1:
- asyncio_log.exception('Accept failed')
+ logger.exception('Accept failed')
sock.close()
except futures.CancelledError:
sock.close()
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index bae9a49..e8ae885 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -17,7 +17,7 @@ from . import events
from . import futures
from . import selectors
from . import transports
-from .log import asyncio_log
+from .log import logger
class BaseSelectorEventLoop(base_events.BaseEventLoop):
@@ -31,7 +31,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
if selector is None:
selector = selectors.DefaultSelector()
- asyncio_log.debug('Using selector: %s', selector.__class__.__name__)
+ logger.debug('Using selector: %s', selector.__class__.__name__)
self._selector = selector
self._make_self_pipe()
@@ -105,7 +105,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
sock.close()
# There's nowhere to send the error, so just log it.
# TODO: Someone will want an error handler for this.
- asyncio_log.exception('Accept failed')
+ logger.exception('Accept failed')
else:
if ssl:
self._make_ssl_transport(
@@ -363,7 +363,7 @@ class _SelectorTransport(transports.Transport):
def _fatal_error(self, exc):
# should be called from exception handler only
- asyncio_log.exception('Fatal error for %s', self)
+ logger.exception('Fatal error for %s', self)
self._force_close(exc)
def _force_close(self, exc):
@@ -444,7 +444,7 @@ class _SelectorSocketTransport(_SelectorTransport):
if self._conn_lost:
if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
- asyncio_log.warning('socket.send() raised exception.')
+ logger.warning('socket.send() raised exception.')
self._conn_lost += 1
return
@@ -667,7 +667,7 @@ class _SelectorSslTransport(_SelectorTransport):
if self._conn_lost:
if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
- asyncio_log.warning('socket.send() raised exception.')
+ logger.warning('socket.send() raised exception.')
self._conn_lost += 1
return
@@ -714,7 +714,7 @@ class _SelectorDatagramTransport(_SelectorTransport):
if self._conn_lost and self._address:
if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
- asyncio_log.warning('socket.send() raised exception.')
+ logger.warning('socket.send() raised exception.')
self._conn_lost += 1
return
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 2c8579f..6385017 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -16,7 +16,7 @@ import weakref
from . import events
from . import futures
-from .log import asyncio_log
+from .log import logger
# If you set _DEBUG to true, @coroutine will wrap the resulting
# generator objects in a CoroWrapper instance (defined below). That
@@ -62,8 +62,8 @@ class CoroWrapper:
code = func.__code__
filename = code.co_filename
lineno = code.co_firstlineno
- asyncio_log.error('Coroutine %r defined at %s:%s was never yielded from',
- func.__name__, filename, lineno)
+ logger.error('Coroutine %r defined at %s:%s was never yielded from',
+ func.__name__, filename, lineno)
def coroutine(func):
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index a3a8e11..34b2aea 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -18,7 +18,7 @@ from . import protocols
from . import selector_events
from . import tasks
from . import transports
-from .log import asyncio_log
+from .log import logger
__all__ = ['SelectorEventLoop', 'STDIN', 'STDOUT', 'STDERR']
@@ -79,7 +79,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
try:
signal.set_wakeup_fd(-1)
except ValueError as nexc:
- asyncio_log.info('set_wakeup_fd(-1) failed: %s', nexc)
+ logger.info('set_wakeup_fd(-1) failed: %s', nexc)
if exc.errno == errno.EINVAL:
raise RuntimeError('sig {} cannot be caught'.format(sig))
@@ -124,7 +124,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
try:
signal.set_wakeup_fd(-1)
except ValueError as exc:
- asyncio_log.info('set_wakeup_fd(-1) failed: %s', exc)
+ logger.info('set_wakeup_fd(-1) failed: %s', exc)
return True
@@ -185,7 +185,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
if transp is not None:
transp._process_exited(returncode)
except Exception:
- asyncio_log.exception('Unknown exception in SIGCHLD handler')
+ logger.exception('Unknown exception in SIGCHLD handler')
def _subprocess_closed(self, transport):
pid = transport.get_pid()
@@ -244,7 +244,7 @@ class _UnixReadPipeTransport(transports.ReadTransport):
def _fatal_error(self, exc):
# should be called by exception handler only
- asyncio_log.exception('Fatal error for %s', self)
+ logger.exception('Fatal error for %s', self)
self._close(exc)
def _close(self, exc):
@@ -294,8 +294,8 @@ class _UnixWritePipeTransport(transports.WriteTransport):
if self._conn_lost or self._closing:
if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES:
- asyncio_log.warning('pipe closed by peer or '
- 'os.write(pipe, data) raised exception.')
+ logger.warning('pipe closed by peer or '
+ 'os.write(pipe, data) raised exception.')
self._conn_lost += 1
return
@@ -369,7 +369,7 @@ class _UnixWritePipeTransport(transports.WriteTransport):
def _fatal_error(self, exc):
# should be called by exception handler only
- asyncio_log.exception('Fatal error for %s', self)
+ logger.exception('Fatal error for %s', self)
self._close(exc)
def _close(self, exc=None):
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index 1d0ad26..bbeada8 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -11,7 +11,7 @@ from . import proactor_events
from . import selector_events
from . import tasks
from . import windows_utils
-from .log import asyncio_log
+from .log import logger
try:
import _overlapped
@@ -139,7 +139,7 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
f = self._proactor.accept_pipe(pipe)
except OSError:
if pipe and pipe.fileno() != -1:
- asyncio_log.exception('Pipe accept failed')
+ logger.exception('Pipe accept failed')
pipe.close()
except futures.CancelledError:
if pipe:
@@ -367,7 +367,7 @@ class IocpProactor:
while self._cache:
if not self._poll(1):
- asyncio_log.debug('taking long time to close proactor')
+ logger.debug('taking long time to close proactor')
self._results = []
if self._iocp is not None: