Spaces:
Running
Running
Commit ·
abfb114
1
Parent(s): 1eb3f81
update
Browse files
api.py
CHANGED
|
@@ -11,6 +11,7 @@ import sys
|
|
| 11 |
import uuid
|
| 12 |
import asyncio
|
| 13 |
import logging
|
|
|
|
| 14 |
from datetime import datetime
|
| 15 |
from typing import List, Dict, Any, Optional
|
| 16 |
from collections import deque
|
|
@@ -70,11 +71,14 @@ class InMemoryLogHandler(logging.Handler):
|
|
| 70 |
|
| 71 |
def emit(self, record):
|
| 72 |
try:
|
|
|
|
|
|
|
|
|
|
| 73 |
log_entry = {
|
| 74 |
"timestamp": datetime.fromtimestamp(record.created).isoformat(),
|
| 75 |
"level": record.levelname,
|
| 76 |
"logger": record.name,
|
| 77 |
-
"message":
|
| 78 |
}
|
| 79 |
self.logs.append(log_entry)
|
| 80 |
except Exception:
|
|
|
|
| 11 |
import uuid
|
| 12 |
import asyncio
|
| 13 |
import logging
|
| 14 |
+
import traceback
|
| 15 |
from datetime import datetime
|
| 16 |
from typing import List, Dict, Any, Optional
|
| 17 |
from collections import deque
|
|
|
|
| 71 |
|
| 72 |
def emit(self, record):
|
| 73 |
try:
|
| 74 |
+
message = self.format(record)
|
| 75 |
+
if record.exc_info:
|
| 76 |
+
message = f"{message}\n{traceback.format_exception(*record.exc_info)}"
|
| 77 |
log_entry = {
|
| 78 |
"timestamp": datetime.fromtimestamp(record.created).isoformat(),
|
| 79 |
"level": record.levelname,
|
| 80 |
"logger": record.name,
|
| 81 |
+
"message": message,
|
| 82 |
}
|
| 83 |
self.logs.append(log_entry)
|
| 84 |
except Exception:
|