mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-16 09:53:04 +00:00
feat: summarize warnings and errors after linking and unlinking
This commit is contained in:
@@ -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<std::unique_ptr<Zone>> m_loaded_zones;
|
||||
};
|
||||
|
||||
@@ -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<std::unique_ptr<Zone>> m_loaded_zones;
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <string>
|
||||
@@ -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<unsigned>(_globalLogLevel) > static_cast<unsigned>(LogLevel::WARN))
|
||||
return;
|
||||
_warn_internal(str);
|
||||
@@ -62,6 +70,7 @@ namespace con
|
||||
|
||||
template<class Arg0, class... OtherArgs> void warn(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
|
||||
{
|
||||
++_warningCount;
|
||||
if (static_cast<unsigned>(_globalLogLevel) > static_cast<unsigned>(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<class Arg0, class... OtherArgs> void error(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
|
||||
{
|
||||
++_errorCount;
|
||||
_error_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
|
||||
}
|
||||
} // namespace con
|
||||
|
||||
Reference in New Issue
Block a user