From d2947da0c5c1de665827ff0e610df7a3e8a579d3 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 15 Apr 2024 11:11:39 +0200 Subject: 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. --- .../execution_engine/executor/executor.hpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (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 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 const& stats, gsl::not_null 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 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 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 stats_; gsl::not_null progress_; + Logger const* logger_; std::chrono::milliseconds timeout_; }; -- cgit v1.2.3