Remove legacy py2.6 backwards logging compat. code
We no longer provide support for py2.6 so we don't need the logging compatibility code to exist anymore. Change-Id: Iaefab67fd8b4e222475d99f57c2c3a7a5ce07d6e
This commit is contained in:
committed by
Joshua Harlow
parent
591da903eb
commit
b64b2b78b6
@@ -17,7 +17,6 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
|
|
||||||
_BASE = __name__.split(".", 1)[0]
|
_BASE = __name__.split(".", 1)[0]
|
||||||
|
|
||||||
@@ -49,45 +48,8 @@ class _BlatherLoggerAdapter(logging.LoggerAdapter):
|
|||||||
self.warning(msg, *args, **kwargs)
|
self.warning(msg, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# TODO(harlowja): we should remove when we no longer have to support 2.6...
|
|
||||||
if sys.version_info[0:2] == (2, 6):
|
|
||||||
|
|
||||||
class _FixedBlatherLoggerAdapter(_BlatherLoggerAdapter):
|
|
||||||
"""Ensures isEnabledFor() exists on adapters that are created."""
|
|
||||||
|
|
||||||
def isEnabledFor(self, level):
|
|
||||||
return self.logger.isEnabledFor(level)
|
|
||||||
|
|
||||||
_BlatherLoggerAdapter = _FixedBlatherLoggerAdapter
|
|
||||||
|
|
||||||
# Taken from python2.7 (same in python3.4)...
|
|
||||||
class _NullHandler(logging.Handler):
|
|
||||||
"""This handler does nothing.
|
|
||||||
|
|
||||||
It's intended to be used to avoid the
|
|
||||||
"No handlers could be found for logger XXX" one-off warning. This is
|
|
||||||
important for library code, which may contain code to log events. If a
|
|
||||||
user of the library does not configure logging, the one-off warning
|
|
||||||
might be produced; to avoid this, the library developer simply needs
|
|
||||||
to instantiate a _NullHandler and add it to the top-level logger of the
|
|
||||||
library module or package.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def handle(self, record):
|
|
||||||
"""Stub."""
|
|
||||||
|
|
||||||
def emit(self, record):
|
|
||||||
"""Stub."""
|
|
||||||
|
|
||||||
def createLock(self):
|
|
||||||
self.lock = None
|
|
||||||
|
|
||||||
else:
|
|
||||||
_NullHandler = logging.NullHandler
|
|
||||||
|
|
||||||
|
|
||||||
def getLogger(name=_BASE, extra=None):
|
def getLogger(name=_BASE, extra=None):
|
||||||
logger = logging.getLogger(name)
|
logger = logging.getLogger(name)
|
||||||
if not logger.handlers:
|
if not logger.handlers:
|
||||||
logger.addHandler(_NullHandler())
|
logger.addHandler(logging.NullHandler())
|
||||||
return _BlatherLoggerAdapter(logger, extra=extra)
|
return _BlatherLoggerAdapter(logger, extra=extra)
|
||||||
|
|||||||
Reference in New Issue
Block a user