set propagate=False on elasticsearch.trace only if logger not already configured
This commit is contained in:
+2
-2
@@ -136,8 +136,8 @@ two loggers: ``elasticsearch`` and ``elasticsearch.trace``. ``elasticsearch``
|
||||
is used by the client to log standard activity, depending on the log level.
|
||||
``elasticsearch.trace`` can be used to log requests to the server in the form
|
||||
of ``curl`` commands using pretty-printed json that can then be executed from
|
||||
command line. The trace logger doesn't inherit from the base one - it needs to
|
||||
be activated separately.
|
||||
command line. If the trace logger has not been configured already it is set to
|
||||
`propagate=False` so it needs to be activated separately.
|
||||
|
||||
.. _logging library: http://docs.python.org/3.3/library/logging.html
|
||||
|
||||
|
||||
@@ -7,8 +7,13 @@ except ImportError:
|
||||
from ..exceptions import TransportError, HTTP_EXCEPTIONS
|
||||
|
||||
logger = logging.getLogger('elasticsearch')
|
||||
|
||||
# create the elasticsearch.trace logger, but only set propagate to False if the
|
||||
# logger hasn't already been configured
|
||||
_tracer_already_configured = 'elasticsearch.trace' in logging.Logger.manager.loggerDict
|
||||
tracer = logging.getLogger('elasticsearch.trace')
|
||||
tracer.propagate = False
|
||||
tracer.propagate = not _tracer_already_configured
|
||||
|
||||
|
||||
class Connection(object):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user