From a80aeae081512dbe165e4d46a76bb0499b349ba7 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 17 Jun 2024 11:09:53 +0200 Subject: executor: properly separate stdout and stderr in log messages ... about processes producing both, stdout and stderr. By supporting unique readability of the output, we facilitate the understanding of the messages provided by actions. --- src/buildtool/execution_engine/executor/executor.hpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/buildtool/execution_engine/executor/executor.hpp') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index ad933a93..d84f4e7e 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -45,6 +45,7 @@ #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/progress_reporting/progress.hpp" #include "src/utils/cpp/hex_string.hpp" +#include "src/utils/cpp/prefix.hpp" /// \brief Implementations for executing actions and uploading artifacts. class ExecutorImpl { @@ -594,20 +595,27 @@ class ExecutorImpl { auto build_message = [has_err, has_out, &logger, &action, &response]() { using namespace std::string_literals; auto message = ""s; + bool has_both = has_err and has_out; if (has_err or has_out) { - message += (has_err and has_out ? "Stdout and stderr"s - : has_out ? "Stdout"s - : "Stderr"s) + + message += (has_both ? "Output"s + : has_out ? "Stdout"s + : "Stderr"s) + " of command "; } message += nlohmann::json(action->Command()).dump() + " in environment " + nlohmann::json(action->Env()).dump() + "\n"; if (response->HasStdOut()) { - message += response->StdOut(); + if (has_both) { + message += "Stdout:\n"; + } + message += PrefixLines(response->StdOut()); } if (response->HasStdErr()) { - message += response->StdErr(); + if (has_both) { + message += "Stderr:\n"; + } + message += PrefixLines(response->StdErr()); } return message; }; -- cgit v1.2.3