From 91185f4f7c84b93ef5c7e9ee95665022e89d1a90 Mon Sep 17 00:00:00 2001 From: ken Date: Thu, 28 Nov 2024 22:16:54 -0800 Subject: [PATCH] Core: Add timestamps to logging for seed generation (#3028) * Add timestamps to logging for improved debugging * Add datetime to general logging; particularly useful for large seeds. * Move console timestamps from Main to Utils.init_logging (better location) * Update Main.py remove spurious blank line Co-authored-by: Nicholas Saylor <79181893+nicholassaylor@users.noreply.github.com> --------- Co-authored-by: Zach Parks Co-authored-by: Nicholas Saylor <79181893+nicholassaylor@users.noreply.github.com> --- Utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Utils.py b/Utils.py index cd0a8971..4e8d7fc4 100644 --- a/Utils.py +++ b/Utils.py @@ -515,10 +515,13 @@ def init_logging(name: str, loglevel: typing.Union[str, int] = logging.INFO, wri 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)) root_logger.addHandler(file_handler) if sys.stdout: + formatter = logging.Formatter(fmt='[%(asctime)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S') stream_handler = logging.StreamHandler(sys.stdout) stream_handler.addFilter(Filter("NoFile", lambda record: not getattr(record, "NoStream", False))) + stream_handler.setFormatter(formatter) root_logger.addHandler(stream_handler) # Relay unhandled exceptions to logger.