commit c54ef5a8da5c3c1bda359df08e6eecb6c77a3f4a
parent a507c08bfe4fa59497091dc800f04ccab37f16b8
Author: James Prestwood <prestwoj@gmail.com>
Date: Wed, 14 Feb 2024 11:30:21 -0800
auto-t: timestamp log files in test-runner
The log files become much more useful when there are timestamps
associated with each log.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git 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.