def test_callsWrappedObserver(self):
     """
     The wrapper always runs the wrapped observer in the end.
     """
     o = call_recorder(lambda *a, **kw: None)
     JSONLogObserverWrapper(o)({'message': ('hello',)})
     assert 1 == len(o.calls)
 def test_jsonifiesPlainLogEntries(self):
     """
     Entries that aren't formatted by JSONRenderer are rendered as JSON
     now.
     """
     o = call_recorder(lambda *a, **kw: None)
     JSONLogObserverWrapper(o)({'message': ('hello',), 'system': '-'})
     msg = json.loads(o.calls[0].args[0]['message'][0])
     assert msg == {'event': 'hello', 'system': '-'}
Exemple #3
0
    def test_leavesStructLogAlone(self):
        """
        Entries that are formatted by JSONRenderer are left alone.
        """
        d = {"message": ("hello", ), "_structlog": True}

        def verify(eventDict):
            assert d == eventDict

        JSONLogObserverWrapper(verify)(d)
Exemple #4
0
    def test_jsonifiesPlainLogEntries(self):
        """
        Entries that aren't formatted by JSONRenderer are rendered as JSON
        now.
        """
        o = call_recorder(lambda *a, **kw: None)
        JSONLogObserverWrapper(o)({"message": ("hello", ), "system": "-"})
        msg = json.loads(o.calls[0].args[0]["message"][0])

        assert msg == {"event": "hello", "system": "-"}