From 409c915375ab2116d69f1bd40ec5d56331e4b3fd Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Sun, 1 Dec 2024 12:37:17 +0100 Subject: [PATCH] Fix crash when trying to log an exception In https://github.com/ArchipelagoMW/Archipelago/pull/3028, we added a new logging filter which checked `record.msg`. However, you can pass whatever you want into a logging call. In this case, what we missed was https://github.com/ArchipelagoMW/Archipelago/blob/ecc3094c70b3ee1f3e18d9299c03198564ec261a/MultiServer.py#L530C1-L530C37, where we pass an Exception object as the message. This currently causes a crash with the new filter. The logging module supports this. It has no typing and can handle passing objects as messages just fine. What you're supposed to use, as far as I understand it, is `record.getMessage()` instead of `record.msg`. --- Utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils.py b/Utils.py index 4f99d26ac4..615016bcea 100644 --- a/Utils.py +++ b/Utils.py @@ -515,7 +515,7 @@ def init_logging(name: str, loglevel: typing.Union[str, int] = logging.INFO, return self.condition(record) file_handler.addFilter(Filter("NoStream", lambda record: not getattr(record, "NoFile", False))) - file_handler.addFilter(Filter("NoCarriageReturn", lambda record: '\r' not in record.msg)) + file_handler.addFilter(Filter("NoCarriageReturn", lambda record: '\r' not in record.getMessage())) root_logger.addHandler(file_handler) if sys.stdout: formatter = logging.Formatter(fmt='[%(asctime)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')