Add NullHandler to logger for all Python versions (#896)
This commit is contained in:
@@ -1,18 +1,22 @@
|
|||||||
|
#flake8: noqa
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
VERSION = (6, 3, 1)
|
VERSION = (6, 3, 1)
|
||||||
__version__ = VERSION
|
__version__ = VERSION
|
||||||
__versionstr__ = '.'.join(map(str, VERSION))
|
__versionstr__ = '.'.join(map(str, VERSION))
|
||||||
|
|
||||||
|
import logging
|
||||||
|
try: # Python 2.7+
|
||||||
|
from logging import NullHandler
|
||||||
|
except ImportError:
|
||||||
|
class NullHandler(logging.Handler):
|
||||||
|
def emit(self, record):
|
||||||
|
pass
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if (2, 7) <= sys.version_info < (3, 2):
|
logger = logging.getLogger('elasticsearch')
|
||||||
# On Python 2.7 and Python3 < 3.2, install no-op handler to silence
|
logger.addHandler(logging.NullHandler())
|
||||||
# `No handlers could be found for logger "elasticsearch"` message per
|
|
||||||
# <https://docs.python.org/2/howto/logging.html#configuring-logging-for-a-library>
|
|
||||||
import logging
|
|
||||||
logger = logging.getLogger('elasticsearch')
|
|
||||||
logger.addHandler(logging.NullHandler())
|
|
||||||
|
|
||||||
from .client import Elasticsearch
|
from .client import Elasticsearch
|
||||||
from .transport import Transport
|
from .transport import Transport
|
||||||
|
|||||||
Reference in New Issue
Block a user