Skip to content

Commit 8ecb756

Browse files
committed
added more keys to the records,
Key names are now consistent with those from logger.LogRecord. I've not dumped the whole record in, in case that's insecure - input welcomed on that issue!
1 parent 97c3e53 commit 8ecb756

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

labthings/core/tasks/thread.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,11 @@ def check_thread(self, record):
243243
def emit(self, record):
244244
"""Do something with a logged message"""
245245
print("emitting a log")
246-
self.dest.append({
247-
"time": record.created,
248-
"level": record.levelname,
249-
"message": record.getMessage(),
250-
})
246+
record_dict = {"message": record.getMessage()}
247+
for k in ["created", "levelname", "levelno", "lineno", "filename"]:
248+
record_dict[k] = getattr(record, k)
249+
self.dest.append(record_dict)
251250
# FIXME: make sure this doesn't become a memory disaster!
252-
# We probably need to check the size of the list...
251+
# We probably need to check the size of the list...
252+
# TODO: think about whether any of the keys are security flaws
253+
# (this is why I don't dump the whole logrecord)

0 commit comments

Comments
 (0)