Log capturing¶
logot
makes it easy to capture logs from the stdlib logging
module:
with Logot().capturing() as logot:
do_something()
logot.assert_logged(logged.info("Something was done"))
See also
See Logging frameworks for other supported logging frameworks.
Test framework integrations¶
Use a supported test framework integration for automatic log capturing in tests:
Configuring¶
The Logot.capturing()
method defaults to capturing all records from the root logger. Customize this with the
level
and name
arguments to Logot.capturing()
:
with Logot().capturing(level=logging.WARNING, name="app") as logot:
do_something()
logot.assert_logged(logged.info("Something was done"))
For advanced use-cases, multiple Logot.capturing()
calls on the same Logot
instance are supported. Be
careful to avoid capturing duplicate logs with overlapping calls to Logot.capturing()
!
See also
See Logot
and Logot.capturing()
API reference.