From: Jeremy Stanley Date: Sat, 27 Apr 2019 19:13:58 +0000 (+0000) Subject: Use ISO 8601 time in logs X-Git-Tag: 0.0.1~27 X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=b7a0d21774ff74bcf66315a4d14b788263f41dea;p=mudpy.git Use ISO 8601 time in logs For ease of readability, switch log timestamps from traditional "asctime" format to ISO 8601 date and time. --- diff --git a/mudpy/misc.py b/mudpy/misc.py index 76f4099..0e7e561 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -5,6 +5,7 @@ # provided in the LICENSE file distributed with this software. import codecs +import datetime import os import random import re @@ -986,7 +987,7 @@ def log(message, level=0): file_name = "" max_log_lines = 0 syslog_name = "" - timestamp = time.asctime()[4:19] + timestamp = datetime.datetime.now().isoformat(' ') # turn the message into a list of nonempty lines lines = [x for x in [(x.rstrip()) for x in message.split("\n")] if x != ""] diff --git a/mudpy/tests/selftest.py b/mudpy/tests/selftest.py index 2cbed03..3b00b48 100644 --- a/mudpy/tests/selftest.py +++ b/mudpy/tests/selftest.py @@ -181,7 +181,7 @@ test_telnet_iac = ( # unescaped and deduplicated to a single \xff in the buffer and then # the line of input discarded as a non-ASCII sequence (2, "> ", b"say argle\xff\xffbargle\r\0"), - (2, r"Non-ASCII characters from admin: b'say argle\\xffbargle'.*> ", ""), + (2, r"Non-ASCII characters from admin: b'say.*argle\\xffbargle'.*> ", ""), ) test_telnet_unknown_command = (