summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_engine/executor
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-04-15 11:11:39 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-04-15 18:05:12 +0200
commitd2947da0c5c1de665827ff0e610df7a3e8a579d3 (patch)
tree4e1d8a1a56f0f196a6efb0f6e5af8e62f4eae236 /src/buildtool/execution_engine/executor
parentd8566f702f831a59f998e9cd765973e224954108 (diff)
downloadjustbuild-d2947da0c5c1de665827ff0e610df7a3e8a579d3.tar.gz
executor: Log in caller logger if given
This means that on the serve endpoint, where a logger for the GraphTraverser is explicitly set, the log messages during action execution is also made available to the client via the CAS-stored analysis and build log blob.
Diffstat (limited to 'src/buildtool/execution_engine/executor')
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 046a6a4c..ca174c84 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -688,6 +688,7 @@ class Executor {
ServerAddress>> dispatch_list,
gsl::not_null<Statistics*> const& stats,
gsl::not_null<Progress*> const& progress,
+ Logger const* logger = nullptr, // log in caller logger, if given
std::chrono::milliseconds timeout = IExecutionAction::kDefaultTimeout)
: repo_config_{repo_config},
local_api_{local_api},
@@ -696,6 +697,7 @@ class Executor {
dispatch_list_{std::move(dispatch_list)},
stats_{stats},
progress_{progress},
+ logger_{logger},
timeout_{timeout} {}
/// \brief Run an action in a blocking manner
@@ -705,6 +707,26 @@ class Executor {
[[nodiscard]] auto Process(
gsl::not_null<DependencyGraph::ActionNode const*> const& action)
const noexcept -> bool {
+ // to avoid always creating a logger we might not need, which is a
+ // non-copyable and non-movable object, we need some code duplication
+ if (logger_ != nullptr) {
+ auto const response = Impl::ExecuteAction(
+ *logger_,
+ action,
+ remote_api_,
+ Impl::MergeProperties(properties_,
+ action->ExecutionProperties()),
+ dispatch_list_,
+ Impl::ScaleTime(timeout_, action->TimeoutScale()),
+ action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput,
+ stats_,
+ progress_);
+ // check response and save digests of results
+ return not response or
+ Impl::ParseResponse(
+ *logger_, *response, action, stats_, progress_);
+ }
+
Logger logger("action:" + action->Content().Id());
auto const response = Impl::ExecuteAction(
@@ -731,6 +753,13 @@ class Executor {
[[nodiscard]] auto Process(
gsl::not_null<DependencyGraph::ArtifactNode const*> const& artifact)
const noexcept -> bool {
+ // to avoid always creating a logger we might not need, which is a
+ // non-copyable and non-movable object, we need some code duplication
+ if (logger_ != nullptr) {
+ return Impl::VerifyOrUploadArtifact(
+ *logger_, artifact, repo_config_, remote_api_, local_api_);
+ }
+
Logger logger("artifact:" + ToHexString(artifact->Content().Id()));
return Impl::VerifyOrUploadArtifact(
logger, artifact, repo_config_, remote_api_, local_api_);
@@ -745,6 +774,7 @@ class Executor {
dispatch_list_;
gsl::not_null<Statistics*> stats_;
gsl::not_null<Progress*> progress_;
+ Logger const* logger_;
std::chrono::milliseconds timeout_;
};