feat(tools): add command arguments in the logs produced by RunTool

Currrently, all logs generated by RunTool are stored in files named
idf_py_(stdout|stderr)_output_$$, making it difficult to identify which
log corresponds to which command. To simplify this for idf-diag, include
the command arguments at the beginning of the log. This will allow
idf-diag to use regex to differentiate logs for build, monitor, flash,
and other commands and targets.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2024-11-30 17:31:39 +01:00
parent 10b0d1fa1b
commit 642855c952

View File

@@ -434,6 +434,8 @@ class RunTool:
# contains CRLF. Use "newline=''" to prevent python to convert CRLF into CRCRLF.
# Please see "newline" description at https://docs.python.org/3/library/functions.html#open
with open(output_filename, 'w', encoding='utf8', newline='') as output_file:
# Log the command arguments.
output_file.write('Command: {}\n'.format(' '.join(self.args)))
while True:
if self.interactive:
output = await read_interactive_stream()