Add structured logging via stdlib logging module
- INFO -> stdout (journal priority info), WARNING/ERROR -> stderr (err) - no-validity-window skip for wyby users is now a WARNING (interface bug hint) - setup_logging(force=True) rebinding handlers, covered by tests - SyslogIdentifier in systemd unit; README logging section (German)
This commit is contained in:
@@ -168,13 +168,29 @@ class TestMainApply:
|
||||
calls = install_rpc(codes=codes)
|
||||
run_main(monkeypatch, "--apply")
|
||||
|
||||
out = capsys.readouterr().out
|
||||
captured = capsys.readouterr()
|
||||
writes = [p for m, p in calls if m == "eAccess.setModel"]
|
||||
assert len(writes) == 1
|
||||
assert writes[0][1]["id"] == "1"
|
||||
assert "no validity window" in out
|
||||
assert "already full-day" in out
|
||||
assert "already expired" in out
|
||||
assert "no validity window" in captured.err # suspicious -> WARNING
|
||||
assert "already full-day" in captured.out
|
||||
assert "already expired" in captured.out
|
||||
|
||||
def test_log_routing_info_stdout_problems_stderr(
|
||||
self, install_rpc, monkeypatch, capsys
|
||||
):
|
||||
codes = [
|
||||
code_row(id=1),
|
||||
code_row(id=2, code="111111", validFrom=None, validTo=None),
|
||||
]
|
||||
install_rpc(codes=codes)
|
||||
run_main(monkeypatch)
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert "PLAN" in captured.out
|
||||
assert "PLAN" not in captured.err
|
||||
assert "no validity window" in captured.err
|
||||
assert "no validity window" not in captured.out
|
||||
|
||||
def test_only_code_filter(self, install_rpc, monkeypatch, capsys):
|
||||
codes = [code_row(id=1, code="225313"), code_row(id=2, code="999999")]
|
||||
@@ -185,14 +201,20 @@ class TestMainApply:
|
||||
assert len(writes) == 1
|
||||
assert writes[0][1]["code"] == "999999"
|
||||
|
||||
def test_write_result_without_id_counts_as_failure(self, install_rpc, monkeypatch):
|
||||
def test_write_result_without_id_counts_as_failure(
|
||||
self, install_rpc, monkeypatch, capsys
|
||||
):
|
||||
install_rpc(codes=[code_row()], write_result={})
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
run_main(monkeypatch, "--apply")
|
||||
assert excinfo.value.code == 1
|
||||
assert "UNCLEAR" in capsys.readouterr().err
|
||||
|
||||
def test_rpc_error_during_write_exits_nonzero(self, install_rpc, monkeypatch):
|
||||
def test_rpc_error_during_write_exits_nonzero(
|
||||
self, install_rpc, monkeypatch, capsys
|
||||
):
|
||||
install_rpc(codes=[code_row()], write_error="HTTP 500: boom")
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
run_main(monkeypatch, "--apply")
|
||||
assert excinfo.value.code == 1
|
||||
assert "ERROR" in capsys.readouterr().err
|
||||
|
||||
Reference in New Issue
Block a user