diff --git a/src/Linking/Linker.cpp b/src/Linking/Linker.cpp index dc710d4d..0b35d380 100644 --- a/src/Linking/Linker.cpp +++ b/src/Linking/Linker.cpp @@ -155,7 +155,7 @@ namespace class LinkerImpl final : public Linker { public: - LinkerImpl(LinkerArgs args) + explicit LinkerImpl(LinkerArgs args) : m_args(std::move(args)) { } @@ -187,6 +187,8 @@ namespace UnloadZones(); + Summarize(result); + return result; } @@ -464,6 +466,12 @@ namespace return true; } + static void Summarize(const bool result) + { + const char* resultStr = result ? "Finished" : "Failed"; + con::info("{} with {} warnings, {} errors", resultStr, con::warning_count(), con::error_count()); + } + LinkerArgs m_args; std::vector> m_loaded_zones; }; diff --git a/src/Unlinking/Unlinker.cpp b/src/Unlinking/Unlinker.cpp index 771f6bb8..ecdd404d 100644 --- a/src/Unlinking/Unlinker.cpp +++ b/src/Unlinking/Unlinker.cpp @@ -42,6 +42,9 @@ namespace const auto result = UnlinkZones(paths); UnloadZones(); + + Summarize(result); + return result; } @@ -307,6 +310,12 @@ namespace return true; } + static void Summarize(const bool result) + { + const char* resultStr = result ? "Finished" : "Failed"; + con::info("{} with {} warnings, {} errors", resultStr, con::warning_count(), con::error_count()); + } + UnlinkerArgs m_args; std::vector> m_loaded_zones; }; diff --git a/src/Utils/Utils/Logging/Log.cpp b/src/Utils/Utils/Logging/Log.cpp index 4cf7db50..f2611242 100644 --- a/src/Utils/Utils/Logging/Log.cpp +++ b/src/Utils/Utils/Logging/Log.cpp @@ -48,6 +48,8 @@ namespace namespace con { LogLevel _globalLogLevel = LogLevel::INFO; + std::atomic_size_t _warningCount(0); + std::atomic_size_t _errorCount(0); void init() { @@ -70,6 +72,22 @@ namespace con globalUseColor = value && CanUseColor(); } + void reset_counts() + { + _warningCount = 0; + _errorCount = 0; + } + + size_t warning_count() + { + return _warningCount; + } + + size_t error_count() + { + return _errorCount; + } + void _debug_internal(const std::string& str) { if (globalUseColor) diff --git a/src/Utils/Utils/Logging/Log.h b/src/Utils/Utils/Logging/Log.h index f6751e12..814d57d5 100644 --- a/src/Utils/Utils/Logging/Log.h +++ b/src/Utils/Utils/Logging/Log.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -15,11 +16,17 @@ namespace con }; extern LogLevel _globalLogLevel; + extern std::atomic_size_t _warningCount; + extern std::atomic_size_t _errorCount; void init(); void set_log_level(LogLevel value); void set_use_color(bool value); + void reset_counts(); + [[nodiscard]] size_t warning_count(); + [[nodiscard]] size_t error_count(); + void _debug_internal(const std::string& str); void _info_internal(const std::string& str); void _warn_internal(const std::string& str); @@ -55,6 +62,7 @@ namespace con inline void warn(const std::string& str) { + ++_warningCount; if (static_cast(_globalLogLevel) > static_cast(LogLevel::WARN)) return; _warn_internal(str); @@ -62,6 +70,7 @@ namespace con template void warn(std::format_string fmt, Arg0&& arg0, OtherArgs&&... otherArgs) { + ++_warningCount; if (static_cast(_globalLogLevel) > static_cast(LogLevel::WARN)) return; _warn_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...))); @@ -69,11 +78,13 @@ namespace con inline void error(const std::string& str) { + ++_errorCount; _error_internal(str); } template void error(std::format_string fmt, Arg0&& arg0, OtherArgs&&... otherArgs) { + ++_errorCount; _error_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...))); } } // namespace con