From c54ef5a8da5c3c1bda359df08e6eecb6c77a3f4a Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 14 Feb 2024 11:30:21 -0800 Subject: [PATCH] auto-t: timestamp log files in test-runner The log files become much more useful when there are timestamps associated with each log. --- tools/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/utils.py b/tools/utils.py index 8219542e..5984fc69 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -6,6 +6,7 @@ import traceback import shutil import dbus +from datetime import datetime from gi.repository import GLib from weakref import WeakValueDictionary from re import fullmatch @@ -125,7 +126,11 @@ class Process(subprocess.Popen): @staticmethod def _write_io(instance, data, stdout=True): for f in instance.write_fds: - f.write(data) + for c in data: + f.write(c) + if c == '\n': + stamp = datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S.%f") + f.write(stamp + ': ') # Write out a separator so multiple process calls per # test are easer to read.