From 56fb551e0b3026b2eeed6280e588464761ee80f6 Mon Sep 17 00:00:00 2001 From: Jared Hancock Date: Sat, 21 Sep 2024 19:51:57 -0500 Subject: [PATCH] logging: Add `ticks` property. `ticks` is the value of `time.ticks_ms()` when the log record is setup. For systems without a millisecond-accurate RTC, such as the RP2, this helps bring time-granularity to log entries. Signed-off-by: Jared Hancock --- python-stdlib/logging/logging.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python-stdlib/logging/logging.py b/python-stdlib/logging/logging.py index f4874df7d..85fc77124 100644 --- a/python-stdlib/logging/logging.py +++ b/python-stdlib/logging/logging.py @@ -36,6 +36,7 @@ def set(self, name, level, message): self.ct = time.time() self.msecs = int((self.ct - int(self.ct)) * 1000) self.asctime = None + self.ticks = time.ticks_ms() class Handler: @@ -102,6 +103,7 @@ def format(self, record): "msecs": record.msecs, "asctime": record.asctime, "levelname": record.levelname, + "ticks": record.ticks, }