Beispiel #1
0
def build_bl(logger=None, processors=None, context=None):
    """
    Convenience function to build BoundLoggerses with sane defaults.
    """
    return BoundLogger(
        logger or ReturnLogger(),
        processors or [KeyValueRenderer()],
        context if context is not None else _CONFIG.default_context_class(),
    )
Beispiel #2
0
def build_bl(logger=None, processors=None, context=None):
    """
    Convenience function to build BoundLoggerses with sane defaults.
    """
    return BoundLogger(
        logger or ReturnLogger(),
        processors or [KeyValueRenderer()],
        context if context is not None else _CONFIG.default_context_class(),
    )
Beispiel #3
0
def build_bl(logger=None, processors=None, context=None):
    """
    Convenience function to build BoundLoggerBases with sane defaults.
    """
    return BoundLoggerBase(
        logger if logger is not None else ReturnLogger(),
        processors if processors is not None else _CONFIG.default_processors,
        context if context is not None else _CONFIG.default_context_class(),
    )
Beispiel #4
0
def build_bl(logger=None, processors=None, context=None):
    """
    Convenience function to build BoundLoggerBases with sane defaults.
    """
    return BoundLoggerBase(
        logger if logger is not None else ReturnLogger(),
        processors if processors is not None else _CONFIG.default_processors,
        context if context is not None else _CONFIG.default_context_class(),
    )
Beispiel #5
0
    def test_deepcopy(self):
        """
        __getattr__ returns None for '__deepcopy__'
        """
        b = BoundLogger(
            ReturnLogger(),
            _CONFIG.default_processors,
            _CONFIG.default_context_class(),
        )

        assert b.__deepcopy__ is None
Beispiel #6
0
 def test_proxies_anything(self):
     """
     Anything that isn't part of BoundLoggerBase gets proxied to the correct
     wrapped logger methods.
     """
     b = BoundLogger(
         ReturnLogger(),
         _CONFIG.default_processors,
         _CONFIG.default_context_class(),
     )
     assert 'log', 'foo' == b.log('foo')
     assert 'gol', 'bar' == b.gol('bar')
Beispiel #7
0
 def test_caches(self):
     """
     __getattr__() gets called only once per logger method.
     """
     b = BoundLogger(
         ReturnLogger(),
         _CONFIG.default_processors,
         _CONFIG.default_context_class(),
     )
     assert 'msg' not in b.__dict__
     b.msg('foo')
     assert 'msg' in b.__dict__
Beispiel #8
0
    def test_proxies_anything(self):
        """
        Anything that isn't part of BoundLoggerBase gets proxied to the correct
        wrapped logger methods.
        """
        b = BoundLogger(
            ReturnLogger(),
            _CONFIG.default_processors,
            _CONFIG.default_context_class(),
        )

        assert "log", "foo" == b.log("foo")
        assert "gol", "bar" == b.gol("bar")
Beispiel #9
0
    def test_pickle(self, proto):
        """
        Can be pickled and unpickled.

        Works only on Python 3: TypeError: can't pickle instancemethod objects
        """
        b = BoundLogger(
            ReturnLogger(),
            _CONFIG.default_processors,
            _CONFIG.default_context_class(),
        ).bind(x=1)

        assert b.info("hi") == pickle.loads(pickle.dumps(b, proto)).info("hi")