aurweb/test/test_logging.py
Kevin Morris a06f4ec19c
fix(fastapi): centralize logging initialization
With this change, we provide a wrapper to `logging.getLogger`
in the `aurweb.logging` module. Modules wishing to log using
logging.conf should get their module-local loggers by calling
`aurweb.logging.getLogger(__name__)`, similar to `logging.getLogger`,
this way initialization with logging.conf is guaranteed.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 10:40:52 -07:00

16 lines
371 B
Python

from aurweb import logging
logger = logging.get_logger(__name__)
def test_logging(caplog):
logger.info("Test log.")
# Test that we logged once.
assert len(caplog.records) == 1
# Test that our log record was of INFO level.
assert caplog.records[0].levelname == "INFO"
# Test that our message got logged.
assert "Test log." in caplog.text