|
|
|
@ -54,7 +54,7 @@ class JSONFormatter(logging.Formatter):
|
|
|
|
"funcName": record.funcName,
|
|
|
|
"funcName": record.funcName,
|
|
|
|
"lineno": record.lineno,
|
|
|
|
"lineno": record.lineno,
|
|
|
|
"pid": os.getpid(),
|
|
|
|
"pid": os.getpid(),
|
|
|
|
"request_id": request_id,
|
|
|
|
"request_id": request_id or "SYSTEM", # request id assigned per request or SYSTEM for system logs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,12 +67,13 @@ class JSONFormatter(logging.Formatter):
|
|
|
|
log_record["stack_trace"] = self.formatStack(record.stack_info)
|
|
|
|
log_record["stack_trace"] = self.formatStack(record.stack_info)
|
|
|
|
|
|
|
|
|
|
|
|
# Add any extra attributes passed to the log call
|
|
|
|
# Add any extra attributes passed to the log call
|
|
|
|
# We skip standard attributes to avoid duplication
|
|
|
|
# We skip standard and internal uvicorn/fastapi attributes to avoid duplication or mess
|
|
|
|
standard_attrs = {
|
|
|
|
standard_attrs = {
|
|
|
|
"args", "asctime", "created", "exc_info", "exc_text", "filename",
|
|
|
|
"args", "asctime", "created", "exc_info", "exc_text", "filename",
|
|
|
|
"funcName", "levelname", "levelno", "lineno", "module", "msecs",
|
|
|
|
"funcName", "levelname", "levelno", "lineno", "module", "msecs",
|
|
|
|
"message", "msg", "name", "pathname", "process", "processName",
|
|
|
|
"message", "msg", "name", "pathname", "process", "processName",
|
|
|
|
"relativeCreated", "stack_info", "thread", "threadName"
|
|
|
|
"relativeCreated", "stack_info", "thread", "threadName",
|
|
|
|
|
|
|
|
"color_message", "request", "scope"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for key, value in record.__dict__.items():
|
|
|
|
for key, value in record.__dict__.items():
|
|
|
|
if key not in standard_attrs:
|
|
|
|
if key not in standard_attrs:
|
|
|
|
|