2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-13 20:21:48 +00:00

chore: update all logging to use centralized logging component

This commit is contained in:
Jan Laupetin
2025-09-10 19:52:42 +02:00
parent 1bf4033f41
commit 02f20f09b6
161 changed files with 824 additions and 664 deletions

View File

@@ -1,5 +1,6 @@
#include "ArgumentParser.h"
#include "Utils/Logging/Log.h"
#include "Utils/StringUtils.h"
#include <filesystem>
@@ -81,7 +82,7 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
if (matchedOption == nullptr)
{
std::cout << std::format("Unknown option '{}'.\n", arg);
con::error("Unknown option '{}'.", arg);
return false;
}
@@ -89,7 +90,7 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
{
if (!matchedOption->m_multi_use)
{
std::cout << std::format("Option '{}' already specified.\n", arg);
con::error("Option '{}' already specified.", arg);
return false;
}
}
@@ -101,7 +102,7 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
const auto parameterCount = static_cast<unsigned>(matchedOption->m_parameters.size());
if (argIndex + parameterCount >= argCount)
{
std::cout << std::format("Not enough parameters for option '{}'.\n", arg);
con::error("Not enough parameters for option '{}'.", arg);
return false;
}
@@ -112,7 +113,7 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
if (param.compare(0, std::char_traits<char>::length(PREFIX_SHORT), PREFIX_SHORT) == 0)
{
std::cout << std::format("Not enough parameters for option '{}'.\n", arg);
con::error("Not enough parameters for option '{}'.", arg);
return false;
}

View File

@@ -1,5 +1,7 @@
#include "UsageInformation.h"
#include "Utils/Logging/Log.h"
#include <iomanip>
#include <iostream>
#include <map>
@@ -105,7 +107,7 @@ void UsageInformation::Print()
}
}
std::cout << str.str() << "\n";
con::info(str.str());
}
void UsageInformation::PrintUsageOverview(std::stringstream& str)

View File

@@ -1,6 +1,7 @@
#pragma once
#include <format>
#include <string>
namespace con
{
@@ -20,29 +21,55 @@ namespace con
void _warn_internal(const std::string& str);
void _error_internal(const std::string& str);
template<class... Args> void debug(std::format_string<Args...> fmt, Args&&... args)
inline void debug(const std::string& str)
{
if (static_cast<unsigned>(globalLogLevel) > static_cast<unsigned>(LogLevel::DEBUG))
return;
_debug_internal(std::vformat(fmt.get(), std::make_format_args(args...)));
_debug_internal(str);
}
template<class... Args> void info(std::format_string<Args...> fmt, Args&&... args)
template<class Arg0, class... OtherArgs> void debug(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
{
if (static_cast<unsigned>(globalLogLevel) > static_cast<unsigned>(LogLevel::DEBUG))
return;
_debug_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
}
inline void info(const std::string& str)
{
if (static_cast<unsigned>(globalLogLevel) > static_cast<unsigned>(LogLevel::INFO))
return;
_info_internal(std::vformat(fmt.get(), std::make_format_args(args...)));
_info_internal(str);
}
template<class... Args> void warn(std::format_string<Args...> fmt, Args&&... args)
template<class Arg0, class... OtherArgs> void info(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
{
if (static_cast<unsigned>(globalLogLevel) > static_cast<unsigned>(LogLevel::INFO))
return;
_info_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
}
inline void warn(const std::string& str)
{
if (static_cast<unsigned>(globalLogLevel) > static_cast<unsigned>(LogLevel::WARN))
return;
_warn_internal(std::vformat(fmt.get(), std::make_format_args(args...)));
_warn_internal(str);
}
template<class... Args> void error(std::format_string<Args...> fmt, Args&&... args)
template<class Arg0, class... OtherArgs> void warn(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
{
_error_internal(std::vformat(fmt.get(), std::make_format_args(args...)));
if (static_cast<unsigned>(globalLogLevel) > static_cast<unsigned>(LogLevel::WARN))
return;
_warn_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
}
inline void error(const std::string& str)
{
_error_internal(str);
}
template<class Arg0, class... OtherArgs> void error(std::format_string<Arg0, OtherArgs...> fmt, Arg0&& arg0, OtherArgs&&... otherArgs)
{
_error_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...)));
}
} // namespace con