From 039184f68c2f1b8b25c0c95ab7febe8569c9c375 Mon Sep 17 00:00:00 2001 From: Mynhardt Burger Date: Fri, 4 Oct 2024 15:29:53 -0400 Subject: [PATCH] Replace usage of time.time() with time.monotonic() for duration calculations Signed-off-by: Mynhardt Burger --- src/python/alog/alog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/alog/alog.py b/src/python/alog/alog.py index 42fc1ed..7fc4d9c 100644 --- a/src/python/alog/alog.py +++ b/src/python/alog/alog.py @@ -822,11 +822,11 @@ def __init__(self, log_fn, format_str="", *args) -> None: def _start_timed_log(self) -> None: """Get the start time for this timed logger.""" - self.start_time = time.time() + self.start_time = time.monotonic() def _end_timed_log(self) -> None: """Gets the end time and prints the end message for this timed logger.""" - duration = timedelta(seconds=time.time() - self.start_time) + duration = timedelta(seconds=time.monotonic() - self.start_time) fmt = self.format_str + "%s" args = list(self.args) + [str(duration)] self.log_fn(fmt, *args, extra={"duration": duration.total_seconds()})