39 Session-scoped TCP server that receives service logs in TSKV format.
41 The server is started once per testsuite session. Static config is patched
42 so that the service can send logs when log capture is enabled for a test.
45 @ref pytest_userver.plugins.service_client.service_client "service_client".capture_logs()
46 instead of this fixture directly. See @ref testsuite_logs_capture.
48 Example — filter captured logs after a request:
50 @snippet samples/testsuite-support/tests/test_logcapture.py select
52 Example — subscribe to log events as they arrive:
54 @snippet samples/testsuite-support/tests/test_logcapture.py subscribe
56 @ingroup userver_testsuite_fixtures
58 host = pytestconfig.option.logs_capture_host
59 port = pytestconfig.option.logs_capture_port
60 if pytestconfig.option.service_wait
or pytestconfig.option.service_disable:
61 port = port
or DEFAULT_PORT
63 server = logcapture.CaptureServer(
64 log_level=logcapture.LogLevel.from_string(userver_log_level),
65 parse_line=_tskv_parse_line,
67 async with server.start(host=host, port=port):
71@pytest.fixture(scope='session')