Using with loguru¶

logot makes it easy to capture logs from loguru:

from logot.loguru import LoguruCapturer

with Logot(capturer=LoguruCapturer).capturing() as logot:
   do_something()
   logot.assert_logged(logged.info("Something was done"))

Installing¶

Ensure logot is installed alongside a compatible loguru version by adding the loguru extra:

pip install 'logot[loguru]'

See also

See Installing package extras usage guide.

Enabling for pytest¶

Enable loguru support in your pytest configuration:

# pytest.ini or .pytest.ini
[pytest]
logot_capturer = logot.loguru.LoguruCapturer
# pyproject.toml
[tool.pytest.ini_options]
logot_capturer = "logot.loguru.LoguruCapturer"

See also

See Using with pytest usage guide.

Enabling for unittest¶

Enable loguru support in your logot.unittest.LogotTestCase:

from logot.loguru import LoguruCapturer

class MyAppTest(LogotTestCase):
   logot_capturer = LoguruCapturer

See also

See Using with unittest usage guide.

Enabling manually¶

Enable loguru support for your Logot instance:

from logot.loguru import LoguruCapturer

logot = Logot(capturer=LoguruCapturer)

Enable loguru support for a single Logot.capturing() call:

with Logot().capturing(capturer=LoguruCapturer) as logot:
   do_something()

See also

See Logot and Logot.capturing() API reference.