summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2020-05-27 15:56:11 +0800
committerCommit Bot <commit-bot@chromium.org>2020-05-30 11:10:25 +0000
commitf680d5e119c0561b33abe350243ff9aa37237788 (patch)
tree635fdee262ade93120258c898fbbf4f028af2c59
parentd96af17c10edb47dd82389da1db47ea7e76f2914 (diff)
downloadchrome-ec-f680d5e119c0561b33abe350243ff9aa37237788.tar.gz
console: add micro seconds in timestamps
A more precise timestamp will be helpful while debugging with AP and EC uart logs. This CL adds extra 3 micro second digits in timestamps, and also uses 'yy' rather than 'YYYY' year format. BRANCH=none BUG=none TEST=sudo emerge ec-devutils; dut-control timestamp:on see cpu_uart_pty in such format: 20-05-27 15:50:36.034 Developer Console 20-05-27 15:50:36.038 20-05-27 15:50:36.038 To return to the browser, press: Change-Id: I782e6e080f38cbaaa31b0b96fac839e118619266 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2217493 Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
-rwxr-xr-xutil/ec3po/console.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/util/ec3po/console.py b/util/ec3po/console.py
index 3643ea498a..c4d1aec23c 100755
--- a/util/ec3po/console.py
+++ b/util/ec3po/console.py
@@ -62,7 +62,7 @@ INTERROGATION_MODES = ['never', 'always', 'auto'] # List of modes which control
# when interrogations are
# performed with the EC.
# Format for printing host timestamp
-HOST_STRFTIME="%Y-%m-%d %H:%M:%S "
+HOST_STRFTIME="%y-%m-%d %H:%M:%S.%f"
class EscState(object):
@@ -858,6 +858,18 @@ class Console(object):
self.look_buffer = self.look_buffer[-LOOK_BUFFER_SIZE:]
+def CanonicalizeTimeString(timestr):
+ """Canonicalize the timestamp string.
+
+ Args:
+ timestr: A timestamp string ended with 6 digits msec.
+
+ Returns:
+ A string with 3 digits msec and an extra space.
+ """
+ return timestr[:-3] + ' '
+
+
def IsPrintable(byte):
"""Determines if a byte is printable.
@@ -1000,7 +1012,7 @@ def StartLoop(console, command_active, shutdown_pipe=None):
# A timestamp is required at the beginning of this line
if tm_req is True:
now = datetime.now()
- tm = now.strftime(HOST_STRFTIME)
+ tm = CanonicalizeTimeString(now.strftime(HOST_STRFTIME))
os.write(console.master_pty, tm)
tm_req = False
@@ -1008,7 +1020,7 @@ def StartLoop(console, command_active, shutdown_pipe=None):
# except if the last character is a newline
nls_found = data.count('\n', 0, end)
now = datetime.now()
- tm = now.strftime('\n' + HOST_STRFTIME)
+ tm = CanonicalizeTimeString(now.strftime('\n' + HOST_STRFTIME))
data_tm = data.replace('\n', tm, nls_found)
else:
data_tm = data