From d156302b055a8c1595a4c96d40ee8adbc94fce77 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 14 Mar 2024 17:07:50 +0100 Subject: WriteTargetCacheEntries: Be explicit in logging location... ...by allowing a Logger instance to be provided. Also adds a flag in order for failed artifacts from builds orchestrated by the serve endpoint to be able to be reported as errors instead of warnings. --- src/buildtool/main/build_utils.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/buildtool/main/build_utils.cpp') diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp index 4b6c7dab..492e80d6 100644 --- a/src/buildtool/main/build_utils.cpp +++ b/src/buildtool/main/build_utils.cpp @@ -15,9 +15,7 @@ #include "src/buildtool/main/build_utils.hpp" #ifndef BOOTSTRAP_BUILD_TOOL #include "src/buildtool/logging/log_level.hpp" -#include "src/buildtool/logging/logger.hpp" #include "src/buildtool/multithreading/async_map_utils.hpp" -#include "src/buildtool/storage/storage.hpp" #include "src/buildtool/storage/target_cache_entry.hpp" #endif // BOOTSTRAP_BUILD_TOOL @@ -162,12 +160,15 @@ void WriteTargetCacheEntries( gsl::not_null const& local_api, gsl::not_null const& remote_api, TargetCacheWriteStrategy strategy, - TargetCache const& tc) { + TargetCache const& tc, + Logger const* logger, + bool strict_logging) { if (strategy == TargetCacheWriteStrategy::Disable) { return; } if (!cache_targets.empty()) { - Logger::Log(LogLevel::Info, + Logger::Log(logger, + LogLevel::Info, "Backing up artifacts of {} export targets", cache_targets.size()); } @@ -187,10 +188,12 @@ void WriteTargetCacheEntries( &ts, cache_targets_ids, []([[maybe_unused]] auto _) {}, // map doesn't set anything - [&failed](auto const& msg, bool fatal) { - Logger::Log(LogLevel::Warning, - "While writing target cache entries:\n{}", - msg); + [&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 = failed or fatal; }); } @@ -200,11 +203,14 @@ void WriteTargetCacheEntries( } if (auto error = DetectAndReportCycle( "writing cache targets", tc_writer_map, kObjectInfoPrinter)) { - Logger::Log(LogLevel::Warning, *error); + Logger::Log(logger, + strict_logging ? LogLevel::Error : LogLevel::Warning, + *error); return; } - Logger::Log(LogLevel::Debug, + Logger::Log(logger, + LogLevel::Debug, "Finished backing up artifacts of export targets"); } #endif // BOOTSTRAP_BUILD_TOOL -- cgit v1.2.3