[+] Initialize rich logger

This commit is contained in:
Azalea Gui
2023-03-07 23:06:46 -05:00
parent ecfa321b76
commit 206b8ebf45
+23
View File
@@ -0,0 +1,23 @@
import logging
def setup_logger(debug: bool):
# Try to use rich for pretty printing
try:
from rich.logging import RichHandler
handler = RichHandler(rich_tracebacks=True)
from rich.traceback import install
install(show_locals=True)
except ImportError:
handler = logging.StreamHandler()
# Initialize debug logger
logging.basicConfig(
level="NOTSET" if debug else "INFO",
format="%(message)s",
datefmt="[%X]",
handlers=[handler]
)
return logging.getLogger("a2")