diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-06 16:33:19 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-06 16:55:26 +0200 |
commit | df4ac66b272d1e26df42855143dda79fc268b558 (patch) | |
tree | dc84f50a5d9d86949b0b2cba7bc4367e90582df8 /src | |
parent | f63d3df866a2d75b694c8c484b21fbcdccd58acd (diff) | |
download | justbuild-df4ac66b272d1e26df42855143dda79fc268b558.tar.gz |
tc writing: allow different log level
... for failures instead of the binary strict_logging. In this
way, we can log at log level Error in the serve instance, and for
the client at level Warning or Info, depending on whether failure
is expected (i.e., if targets are potentially taken from a serve
endpoint) or not.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/main/build_utils.cpp | 17 | ||||
-rw-r--r-- | src/buildtool/main/build_utils.hpp | 3 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 7 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/target.cpp | 2 |
4 files changed, 16 insertions, 13 deletions
diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp index b29ff0c5..fb60ea15 100644 --- a/src/buildtool/main/build_utils.cpp +++ b/src/buildtool/main/build_utils.cpp @@ -160,7 +160,7 @@ void WriteTargetCacheEntries( TargetCacheWriteStrategy strategy, TargetCache<true> const& tc, Logger const* logger, - bool strict_logging) { + LogLevel log_level) { if (strategy == TargetCacheWriteStrategy::Disable) { return; } @@ -186,12 +186,11 @@ void WriteTargetCacheEntries( &ts, cache_targets_ids, []([[maybe_unused]] auto _) {}, // map doesn't set anything - [&failed, logger, strict_logging](auto const& msg, bool fatal) { - Logger::Log( - logger, - strict_logging ? LogLevel::Error : LogLevel::Warning, - "While writing target cache entries:\n{}", - msg); + [&failed, logger, log_level](auto const& msg, bool fatal) { + Logger::Log(logger, + log_level, + "While writing target cache entries:\n{}", + msg); failed = failed or fatal; }); } @@ -201,9 +200,7 @@ void WriteTargetCacheEntries( } if (auto error = DetectAndReportCycle( "writing cache targets", tc_writer_map, kObjectInfoPrinter)) { - Logger::Log(logger, - strict_logging ? LogLevel::Error : LogLevel::Warning, - *error); + Logger::Log(logger, log_level, *error); return; } diff --git a/src/buildtool/main/build_utils.hpp b/src/buildtool/main/build_utils.hpp index 60f2ca97..af99d6a0 100644 --- a/src/buildtool/main/build_utils.hpp +++ b/src/buildtool/main/build_utils.hpp @@ -31,6 +31,7 @@ #include "src/buildtool/common/artifact.hpp" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" +#include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/storage/storage.hpp" @@ -93,7 +94,7 @@ void WriteTargetCacheEntries( TargetCacheWriteStrategy strategy = TargetCacheWriteStrategy::Sync, TargetCache<true> const& tc = Storage::Instance().TargetCache(), Logger const* logger = nullptr, - bool strict_logging = false); + LogLevel log_level = LogLevel::Warning); #endif // BOOTSTRAP_BUILD_TOOL #endif // INCLUDED_SRC_BUILDOOL_MAIN_BUILD_UTILS_HPP diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 9f34122a..b8f5f36d 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -1109,7 +1109,12 @@ auto main(int argc, char* argv[]) -> int { jobs, traverser.GetLocalApi(), traverser.GetRemoteApi(), - arguments.tc.target_cache_write_strategy); + arguments.tc.target_cache_write_strategy, + Storage::Instance().TargetCache(), + nullptr, + arguments.serve.remote_serve_address + ? LogLevel::Performance + : LogLevel::Warning); // Repeat taintedness message to make the user aware that // the artifacts are not for production use. diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index 9f54f7c3..3fc22c73 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -518,7 +518,7 @@ auto TargetService::ServeTarget( RemoteServeConfig::TCStrategy(), tc, &logger, - true /*strict_logging*/); + LogLevel::Error); if (build_result->failed_artifacts) { // report failure locally, to keep track of it... |