summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_engine
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-17 11:09:53 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-17 14:52:52 +0200
commita80aeae081512dbe165e4d46a76bb0499b349ba7 (patch)
tree201c32466e55a7c253797dfc544491effbdc9f8e /src/buildtool/execution_engine
parent168e19a707b9b086a583df031b23aa33f0ca16ac (diff)
downloadjustbuild-a80aeae081512dbe165e4d46a76bb0499b349ba7.tar.gz
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.
Diffstat (limited to 'src/buildtool/execution_engine')
-rw-r--r--src/buildtool/execution_engine/executor/TARGETS1
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp18
2 files changed, 14 insertions, 5 deletions
diff --git a/src/buildtool/execution_engine/executor/TARGETS b/src/buildtool/execution_engine/executor/TARGETS
index 6855f87b..7a7718dd 100644
--- a/src/buildtool/execution_engine/executor/TARGETS
+++ b/src/buildtool/execution_engine/executor/TARGETS
@@ -17,6 +17,7 @@
, ["src/buildtool/execution_api/remote", "bazel"]
, ["src/buildtool/progress_reporting", "progress"]
, ["src/utils/cpp", "hex_string"]
+ , ["src/utils/cpp", "prefix"]
, ["@", "gsl", "", "gsl"]
, ["src/buildtool/common", "common"]
, ["src/buildtool/common/remote", "remote_common"]
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;
};