Skip to content

Commit

Permalink
feat($Loguru): log more details for exception
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Sep 1, 2022
1 parent ab378b0 commit af5260b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python_boilerplate/configuration/loguru_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
format=_message_format,
enqueue=True,
# turn to false if in production to prevent data leaking
backtrace=False,
backtrace=True,
diagnose=True,
rotation="00:00",
retention="7 Days",
compression="gz",
Expand Down
10 changes: 10 additions & 0 deletions tests/configuration/test_loguru_configuration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from loguru import logger

from python_boilerplate.configuration.loguru_configuration import configure


Expand All @@ -6,3 +8,11 @@ def test_configure() -> None:
configure()
except Exception as ex:
assert False, f"{configure} raised an exception {ex}"


def test_log_exception() -> None:
try:
divided_by_zero = 5 / 0
logger.info(f"divided_by_zero = {divided_by_zero}")
except Exception as ex:
logger.exception(f"Oops! Exception occurred. {ex.__str__()}")

0 comments on commit af5260b

Please sign in to comment.