feat: logging

This commit is contained in:
2025-07-28 15:27:17 +04:00
parent 361f94323c
commit 27fb24a44c
10 changed files with 171 additions and 5 deletions

20
logger/formatter.py Normal file
View File

@ -0,0 +1,20 @@
import json
import logging
from datetime import datetime, UTC
class JsonFormatter(logging.Formatter):
def format(self, record: any):
log_record = {
"timestamp": datetime.now(UTC).isoformat(),
"level": record.levelname,
"module": record.module,
"line": record.lineno,
"message": record.getMessage(),
"request_id": record.request_id,
}
if record.exc_info:
log_record["exception"] = self.formatException(record.exc_info)
return json.dumps(log_record)