mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-17 10:23:02 +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
|
class LinkerImpl final : public Linker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LinkerImpl(LinkerArgs args)
|
explicit LinkerImpl(LinkerArgs args)
|
||||||
: m_args(std::move(args))
|
: m_args(std::move(args))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -187,6 +187,8 @@ namespace
|
|||||||
|
|
||||||
UnloadZones();
|
UnloadZones();
|
||||||
|
|
||||||
|
Summarize(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,6 +466,12 @@ namespace
|
|||||||
return true;
|
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;
|
LinkerArgs m_args;
|
||||||
std::vector<std::unique_ptr<Zone>> m_loaded_zones;
|
std::vector<std::unique_ptr<Zone>> m_loaded_zones;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ namespace
|
|||||||
const auto result = UnlinkZones(paths);
|
const auto result = UnlinkZones(paths);
|
||||||
|
|
||||||
UnloadZones();
|
UnloadZones();
|
||||||
|
|
||||||
|
Summarize(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +310,12 @@ namespace
|
|||||||
return true;
|
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;
|
UnlinkerArgs m_args;
|
||||||
std::vector<std::unique_ptr<Zone>> m_loaded_zones;
|
std::vector<std::unique_ptr<Zone>> m_loaded_zones;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ namespace
|
|||||||
namespace con
|
namespace con
|
||||||
{
|
{
|
||||||
LogLevel _globalLogLevel = LogLevel::INFO;
|
LogLevel _globalLogLevel = LogLevel::INFO;
|
||||||
|
std::atomic_size_t _warningCount(0);
|
||||||
|
std::atomic_size_t _errorCount(0);
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
@@ -70,6 +72,22 @@ namespace con
|
|||||||
globalUseColor = value && CanUseColor();
|
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)
|
void _debug_internal(const std::string& str)
|
||||||
{
|
{
|
||||||
if (globalUseColor)
|
if (globalUseColor)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -15,11 +16,17 @@ namespace con
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern LogLevel _globalLogLevel;
|
extern LogLevel _globalLogLevel;
|
||||||
|
extern std::atomic_size_t _warningCount;
|
||||||
|
extern std::atomic_size_t _errorCount;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void set_log_level(LogLevel value);
|
void set_log_level(LogLevel value);
|
||||||
void set_use_color(bool 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 _debug_internal(const std::string& str);
|
||||||
void _info_internal(const std::string& str);
|
void _info_internal(const std::string& str);
|
||||||
void _warn_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)
|
inline void warn(const std::string& str)
|
||||||
{
|
{
|
||||||
|
++_warningCount;
|
||||||
if (static_cast<unsigned>(_globalLogLevel) > static_cast<unsigned>(LogLevel::WARN))
|
if (static_cast<unsigned>(_globalLogLevel) > static_cast<unsigned>(LogLevel::WARN))
|
||||||
return;
|
return;
|
||||||
_warn_internal(str);
|
_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)
|
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))
|
if (static_cast<unsigned>(_globalLogLevel) > static_cast<unsigned>(LogLevel::WARN))
|
||||||
return;
|
return;
|
||||||
_warn_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
|
_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)
|
inline void error(const std::string& str)
|
||||||
{
|
{
|
||||||
|
++_errorCount;
|
||||||
_error_internal(str);
|
_error_internal(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Arg0, class... OtherArgs> void error(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
|
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...)));
|
_error_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
|
||||||
}
|
}
|
||||||
} // namespace con
|
} // namespace con
|
||||||
|
|||||||
Reference in New Issue
Block a user