diff --git a/tools/rosgraph/src/rosgraph/roslogging.py b/tools/rosgraph/src/rosgraph/roslogging.py index 9ecc121893..f8058bf999 100644 --- a/tools/rosgraph/src/rosgraph/roslogging.py +++ b/tools/rosgraph/src/rosgraph/roslogging.py @@ -255,7 +255,7 @@ def emit(self, record): while '${walltime:' in msg: tag_end_index = msg.index('${walltime:') + len('${walltime:') time_format = msg[tag_end_index: msg.index('}', tag_end_index)] - time_str = time.strftime(time_format) + time_str = datetime.datetime.now().strftime(time_format) msg = msg.replace('${walltime:' + time_format + '}', time_str) msg = msg.replace('${thread}', str(record.thread)) @@ -279,7 +279,7 @@ def emit(self, record): while '${time:' in msg: tag_end_index = msg.index('${time:') + len('${time:') time_format = msg[tag_end_index: msg.index('}', tag_end_index)] - time_str = time.strftime(time_format) + time_str = datetime.datetime.now().strftime(time_format) if self._get_time is not None and not self._is_wallclock(): time_str += ', %f' % self._get_time() diff --git a/tools/rosgraph/test/test_roslogging.py b/tools/rosgraph/test/test_roslogging.py index 67fbd75543..34445a8331 100644 --- a/tools/rosgraph/test/test_roslogging.py +++ b/tools/rosgraph/test/test_roslogging.py @@ -47,7 +47,7 @@ '${severity}', '${message}', '${walltime}', - '${walltime:%Y-%m-%d %H:%M:%S}', + '${walltime:%Y-%m-%d %H:%M:%S.%f}', '${thread}', '${logger}', '${file}', @@ -55,7 +55,7 @@ '${function}', '${node}', '${time}', - '${time:%Y-%m-%d %H:%M:%S}', + '${time:%Y-%m-%d %H:%M:%S.%f}', ]) rosgraph.roslogging.configure_logging('test_rosgraph', logging.INFO) loginfo = logging.getLogger('rosout').info @@ -113,7 +113,7 @@ def test_rosconsole__logging_format(): 'INFO', 'on ' + loc, r'[0-9]*\.[0-9]*', - r'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}', + r'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}', '[0-9]*', 'rosout', re.escape(this_file), @@ -122,7 +122,7 @@ def test_rosconsole__logging_format(): # depending if rospy.get_name() is available '(/unnamed|)', r'[0-9]*\.[0-9]*', - r'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}', + r'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}', ]) assert_regexp_matches(lout.getvalue().splitlines()[i], log_out)