Force time.isoformat to show microseconds every time

Fix #158
This commit is contained in:
Ram Rachum 2019-09-14 10:41:24 +03:00
parent e2aa42bd6d
commit bd05c1686f
2 changed files with 18 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import abc
import os
import inspect
import sys
import datetime as datetime_module
PY3 = (sys.version_info[0] == 3)
PY2 = not PY3
@ -64,3 +65,18 @@ try:
from collections import abc as collections_abc
except ImportError: # Python 2.7
import collections as collections_abc
if sys.version_info[:2] >= (3, 6):
time_isoformat = datetime_module.time.isoformat
else:
def time_isoformat(time, timespec='microseconds'):
assert isinstance(time, datetime_module.time)
if timespec != 'microseconds':
raise NotImplementedError
result = '{:02d}:{:02d}:{:02d}.{:06d}'.format(
time.hour, time.minute, time.second, time.microsecond
)
assert len(result) == 15
return result

View file

@ -346,7 +346,8 @@ class Tracer:
# #
### Finished checking whether we should trace this line. ##############
now_string = datetime_module.datetime.now().time().isoformat()
now = datetime_module.datetime.now().time()
now_string = pycompat.time_isoformat(now, timespec='microseconds')
line_no = frame.f_lineno
source_path, source = get_path_and_source_from_frame(frame)
if self.last_source_path != source_path: