-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.py
38 lines (27 loc) · 872 Bytes
/
logger.py
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
31
32
33
34
35
36
37
38
import logging
# Create custom log level
EURAC_LEVEL = 25
logging.addLevelName(EURAC_LEVEL, "EURAC")
def eurac(self, message, *args, **kwargs):
"""
Log with custom EURAC level
"""
if self.isEnabledFor(EURAC_LEVEL):
self._log(EURAC_LEVEL, message, args, **kwargs)
# Add eurac method to Logger class
logging.Logger.eurac = eurac
# Create and configure logger
def get_logger(name="BrickLLM"):
logger = logging.getLogger(name)
# Create handler if none exists
if not logger.handlers:
handler = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(EURAC_LEVEL)
return logger
# Create default logger instance
custom_logger = get_logger()