-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogs.py
More file actions
30 lines (23 loc) · 695 Bytes
/
logs.py
File metadata and controls
30 lines (23 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import logging
from rich.logging import RichHandler
def setup_logging(log_topic: str):
# Reset handlers
root = logging.getLogger()
root.handlers.clear()
logging.basicConfig(
level="DEBUG",
format="%(message)s", # only message, no timestamp/level
handlers=[
RichHandler(
rich_tracebacks=True,
show_time=False, # disable timestamp
show_path=True, # keep file:line info
)
],
)
# Silence root
logging.getLogger().setLevel(logging.CRITICAL)
# Your app logger
logger = logging.getLogger(log_topic)
logger.setLevel(logging.DEBUG)
return logger