def test_json_null(capture: jsonlog.tests.capture.Capture):
    jsonlog.basicConfig()
    jsonlog.warning("No exc_info, traceback should be hidden")
    assert '"traceback": ' not in capture
Example #2
0
import jsonlog

jsonlog.warning("Hello world.")
Example #3
0
def test_ensure_config(capture: jsonlog.tests.capture.Capture):
    jsonlog.warning("Hello world")
    assert '"message": "Hello world"' in capture
Example #4
0
def test_basic_config(capture: jsonlog.tests.capture.Capture):
    jsonlog.basicConfig()
    jsonlog.warning("Hello world")
    assert '"message": "Hello world"' in capture
Example #5
0
"""Tracebacks will be included in the output JSON."""

import jsonlog

jsonlog.warning("Started script")

try:
    raise ValueError("Example exception")
except ValueError:
    jsonlog.exception("Encountered an error")
Example #6
0
"""The jsonlog formatter is configured when you call module-level functions."""

import jsonlog

jsonlog.warning("User %(user)s clicked a button", {"user": 123})