diff --git a/README.md b/README.md index 1760b03..04c65f7 100644 --- a/README.md +++ b/README.md @@ -584,7 +584,15 @@ Logging Injector uses standard :mod:`logging` module, the logger name is ``injector``. -By default ``injector`` logger is configured to use :class:`logging.NullHandler`. +By default ``injector`` logger is not configured to print logs anywhere. + +To enable ``get()`` tracing you need to set ``injector`` logger level to ``DEBUG``. You can do that programatically by executing: + +```pycon +import logging + +logging.getLogger('injector').setLevel(logging.DEBUG) +``` Thread safety ------------- diff --git a/injector.py b/injector.py index 4ab34e5..c6e31ef 100644 --- a/injector.py +++ b/injector.py @@ -37,11 +37,8 @@ __author__ = 'Alec Thomas ' __version__ = '0.7.4' __version_tag__ = '' -# To enable get() tracing, getLogger('injector').setLevel(logging.INFO) -# To enable debug logging, setLevel(logging.DEBUG). log = logging.getLogger('injector') log.addHandler(NullHandler()) -log.setLevel(logging.WARNING) def synchronized(lock): @@ -561,9 +558,9 @@ class Injector(object): raise Error('%s; scopes must be explicitly bound ' 'with Binder.bind_scope(scope_cls)' % e) - log.info('%sInjector.get(%r, annotation=%r, scope=%r) using %r', self._log_prefix, interface, annotation, scope, binding.provider) + log.debug('%sInjector.get(%r, annotation=%r, scope=%r) using %r', self._log_prefix, interface, annotation, scope, binding.provider) result = scope_instance.get(key, binding.provider).get() - log.info('%s -> %r', self._log_prefix, result) + log.debug('%s -> %r', self._log_prefix, result) return result def create_child_injector(self, *args, **kwargs):