Update api/logger.py
Browse files- api/logger.py +5 -5
api/logger.py
CHANGED
@@ -2,11 +2,11 @@ import logging
|
|
2 |
|
3 |
class ChatIDLoggerAdapter(logging.LoggerAdapter):
|
4 |
def process(self, msg, kwargs):
|
5 |
-
#
|
6 |
-
chat_id =
|
7 |
return f"[Chat ID: {chat_id}] {msg}", kwargs
|
8 |
|
9 |
-
def setup_logger(name
|
10 |
logger = logging.getLogger(name)
|
11 |
if not logger.handlers:
|
12 |
logger.setLevel(logging.INFO)
|
@@ -17,5 +17,5 @@ def setup_logger(name, chat_id=None):
|
|
17 |
console_handler.setFormatter(formatter)
|
18 |
logger.addHandler(console_handler)
|
19 |
|
20 |
-
#
|
21 |
-
return ChatIDLoggerAdapter(logger, {
|
|
|
2 |
|
3 |
class ChatIDLoggerAdapter(logging.LoggerAdapter):
|
4 |
def process(self, msg, kwargs):
|
5 |
+
# Check if 'chat_id' is passed in kwargs; otherwise, use 'N/A'
|
6 |
+
chat_id = kwargs.pop('chat_id', 'N/A')
|
7 |
return f"[Chat ID: {chat_id}] {msg}", kwargs
|
8 |
|
9 |
+
def setup_logger(name):
|
10 |
logger = logging.getLogger(name)
|
11 |
if not logger.handlers:
|
12 |
logger.setLevel(logging.INFO)
|
|
|
17 |
console_handler.setFormatter(formatter)
|
18 |
logger.addHandler(console_handler)
|
19 |
|
20 |
+
# Return the LoggerAdapter without a fixed chat_id
|
21 |
+
return ChatIDLoggerAdapter(logger, {})
|