11import re
22import sys
33from logging import Logger
4- from typing import Any , Optional
4+ from typing import Any , Optional , Union
55
66from loguru import logger
77
@@ -36,7 +36,7 @@ def info(self, message: str, **kwargs):
3636 def warning (self , message : str , ** kwargs ):
3737 self .log (message , "warning" , ** kwargs )
3838
39- def error (self , message : str , ** kwargs ):
39+ def error (self , message : Union [ Exception , str ] , ** kwargs ):
4040 self .log (message , "error" , ** kwargs )
4141
4242 def success (self , message : str , ** kwargs ):
@@ -58,7 +58,9 @@ def log(
5858 # Escape XML/HTML tags etc. that look like loguru color directives
5959 # The regexp is coming directly from the loguru source code, see
6060 # https://github.com/Delgan/loguru/blob/master/loguru/_colorizer.py
61- message = re .sub (r"(</?(?:[fb]g\s)?[^<>\s]*>)" , r"\\\1" , message , count = 0 , flags = re .IGNORECASE )
61+ message = re .sub (
62+ r"(</?(?:[fb]g\s)?[^<>\s]*>)" , r"\\\1" , message , count = 0 , flags = re .IGNORECASE
63+ )
6264
6365 # Handle indentation (including multiple lines)
6466 message = self ._indent_text (message , indent )
0 commit comments