Skip to content

Commit 045a964

Browse files
fix(logger): set exc_text to error text if it is none (found via 288)
1 parent 25f0b59 commit 045a964

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

nxc/logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ def __init__(self, formatter=None, *args, **kwargs):
5353

5454
def emit(self, record):
5555
"""Overrides the emit method of the RichHandler class so we can set the proper pathname and lineno"""
56+
# for some reason in RDP, the exc_text is None which leads to a KeyError in Python logging
57+
record.exc_text = record.getMessage() if record.exc_text is None else record.exc_text
58+
5659
if hasattr(record, "caller_frame"):
5760
frame_info = inspect.getframeinfo(record.caller_frame)
5861
record.pathname = frame_info.filename
5962
record.lineno = frame_info.lineno
6063
super().emit(record)
6164

62-
6365
def no_debug(func):
6466
"""Stops logging non-debug messages when we are in debug mode
6567
It creates a temporary logger and logs the message to the console and file

0 commit comments

Comments
 (0)