py.lib
2022-07-17
Parent:9a4eb7660c11
py.lib/log/slog_console.py
. Используем в логах monotonic вместо time
1.1 --- a/log/slog_console.py Sun Jul 17 22:21:37 2022 +0300 1.2 +++ b/log/slog_console.py Sun Jul 17 22:26:31 2022 +0300 1.3 @@ -9,7 +9,7 @@ 1.4 "#": Alert 1.5 """ 1.6 1.7 -from time import time 1.8 +from time import monotonic 1.9 from datetime import timedelta 1.10 from sys import exc_info, stderr, stdout 1.11 from traceback import extract_tb, extract_stack 1.12 @@ -21,23 +21,23 @@ 1.13 self.prefix = '' 1.14 else: 1.15 self.prefix = '%s :: ' % name 1.16 - self.tsAll = time() 1.17 + self.tsAll = monotonic() 1.18 self.ts = self.tsAll 1.19 1.20 def getTime(self): 1.21 - return time() - self.ts 1.22 + return monotonic() - self.ts 1.23 1.24 def reset(self): 1.25 - self.ts = time() 1.26 + self.ts = monotonic() 1.27 self.tsAll = self.ts 1.28 1.29 def __str__(self): 1.30 - ts = time() 1.31 + ts = monotonic() 1.32 return self.prefix + '%s(%.4f)' % (timedelta(seconds=(ts - self.tsAll)), ts - self.ts) 1.33 1.34 def __call__(self, msg): 1.35 _buf = '%s | %s' % (self, msg) 1.36 - self.ts = time() 1.37 + self.ts = monotonic() 1.38 return _buf 1.39 1.40