예제 #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(),
    )
예제 #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(),
    )
예제 #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(),
    )
예제 #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(),
    )
예제 #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
예제 #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')
예제 #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__
예제 #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")
예제 #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")