Spaces:
Sleeping
Sleeping
Asaad Almutareb
commited on
Commit
•
5c0a79d
1
Parent(s):
edc0787
added console logger alternative
Browse files
innovation_pathfinder_ai/utils/logger.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# logger.py
|
2 |
+
|
3 |
+
import logging
|
4 |
+
from rich.logging import RichHandler
|
5 |
+
from typing import Optional
|
6 |
+
|
7 |
+
|
8 |
+
def get_console_logger(name: Optional[str] = "default") -> logging.Logger:
|
9 |
+
logger = logging.getLogger(name)
|
10 |
+
if not logger.handlers:
|
11 |
+
logger.setLevel(logging.DEBUG)
|
12 |
+
console_handler = RichHandler()
|
13 |
+
console_handler.setLevel(logging.DEBUG)
|
14 |
+
formatter = logging.Formatter(
|
15 |
+
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
16 |
+
)
|
17 |
+
console_handler.setFormatter(formatter)
|
18 |
+
logger.addHandler(console_handler)
|
19 |
+
|
20 |
+
return logger
|