diff mbox series

[bitbake-devel] build: prefix the tasks with a timestamp in the log task_order

Message ID 20220805092601.388389-1-jose.quaresma@foundries.io
State New
Headers show
Series [bitbake-devel] build: prefix the tasks with a timestamp in the log task_order | expand

Commit Message

Jose Quaresma Aug. 5, 2022, 9:26 a.m. UTC
This is useful when debugging as it helps understand possible
race conditions between tasks of diferent recipes.

Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
 lib/bb/build.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/build.py b/lib/bb/build.py
index 55f68b98..d998a432 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -25,6 +25,7 @@  import bb.msg
 import bb.process
 import bb.progress
 from bb import data, event, utils
+from datetime import datetime, timezone
 
 bblogger = logging.getLogger('BitBake')
 logger = logging.getLogger('BitBake.Build')
@@ -618,7 +619,8 @@  def _exec_task(fn, task, d, quieterr):
     logorder = os.path.join(tempdir, 'log.task_order')
     try:
         with open(logorder, 'a') as logorderfile:
-            logorderfile.write('{0} ({1}): {2}\n'.format(task, os.getpid(), logbase))
+            timestamp = datetime.now().strftime("%Y%m%d-%H%M%S.%f")
+            logorderfile.write('{0} {1} ({2}): {3}\n'.format(timestamp, task, os.getpid(), logbase))
     except OSError:
         logger.exception("Opening log file '%s'", logorder)
         pass