Initial commit
This commit is contained in:
25
logging_config.py
Normal file
25
logging_config.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
import logging
|
||||
from rich.logging import RichHandler
|
||||
from rich.console import Console
|
||||
|
||||
def setup_logging(level=logging.INFO, debug=False):
|
||||
|
||||
# silence noisy libraries
|
||||
for lib_name in ("urllib3","requests","http.client","markdown","Markdown"):
|
||||
logging.getLogger(lib_name).setLevel(logging.WARNING)
|
||||
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
format="%(message)s",
|
||||
datefmt="[%X]",
|
||||
handlers=[RichHandler(
|
||||
rich_tracebacks=True,
|
||||
show_path=False,
|
||||
log_time_format="[%H:%M:%S]",
|
||||
markup=True
|
||||
)],
|
||||
)
|
||||
|
||||
if debug:
|
||||
logging.getLogger(__name__).debug("[dim]Debug mode active.[/dim]")
|
||||
Reference in New Issue
Block a user