def test_does_not_cache(self): """ Due to doctest weirdness, we must not re-use PrintLoggers. """ f = PrintLoggerFactory() assert f() is not f()
def test_passes_file(self): """ If a file is passed to the factory, it get passed on to the logger. """ pl = PrintLoggerFactory(sys.stderr)() assert sys.stderr is pl._file
def test_ignores_args(self): """ PrintLogger doesn't take positional arguments. If any are passed to the factory, they are not passed to the logger. """ PrintLoggerFactory()(1, 2, 3)
PrintLoggerFactory, ) from structlog.processors import ( KeyValueRenderer, StackInfoRenderer, format_exc_info, ) _BUILTIN_DEFAULT_PROCESSORS = [ StackInfoRenderer(), format_exc_info, KeyValueRenderer(), ] _BUILTIN_DEFAULT_CONTEXT_CLASS = OrderedDict _BUILTIN_DEFAULT_WRAPPER_CLASS = BoundLogger _BUILTIN_DEFAULT_LOGGER_FACTORY = PrintLoggerFactory() _BUILTIN_CACHE_LOGGER_ON_FIRST_USE = False class _Configuration(object): """ Global defaults. """ is_configured = False default_processors = _BUILTIN_DEFAULT_PROCESSORS[:] default_context_class = _BUILTIN_DEFAULT_CONTEXT_CLASS default_wrapper_class = _BUILTIN_DEFAULT_WRAPPER_CLASS logger_factory = _BUILTIN_DEFAULT_LOGGER_FACTORY cache_logger_on_first_use = _BUILTIN_CACHE_LOGGER_ON_FIRST_USE