2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-24 01:06:40 +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,7 @@
#include "ContentPrinter.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -12,11 +14,11 @@ void ContentPrinter::PrintContent() const
{
const auto* pools = m_zone.m_pools.get();
const auto* game = IGame::GetGameById(m_zone.m_game_id);
std::cout << std::format("Zone '{}' ({})\n", m_zone.m_name, game->GetShortName());
std::cout << "Content:\n";
con::info("Zone '{}' ({})", m_zone.m_name, game->GetShortName());
con::info("Content:");
for (const auto& asset : *pools)
std::cout << std::format("{}, {}\n", *pools->GetAssetTypeName(asset->m_type), asset->m_name);
con::info("{}, {}", *pools->GetAssetTypeName(asset->m_type), asset->m_name);
std::cout << "\n";
con::info("");
}

View File

@@ -12,6 +12,7 @@
#include "UnlinkerArgs.h"
#include "UnlinkerPaths.h"
#include "Utils/ClassUtils.h"
#include "Utils/Logging/Log.h"
#include "Utils/ObjFileStream.h"
#include "ZoneLoading.h"
@@ -67,7 +68,7 @@ private:
std::ofstream zoneDefinitionFile(zoneDefinitionFilePath, std::fstream::out | std::fstream::binary);
if (!zoneDefinitionFile.is_open())
{
std::cerr << std::format("Failed to open file for zone definition file of zone \"{}\".\n", zone.m_name);
con::error("Failed to open file for zone definition file of zone \"{}\".", zone.m_name);
return false;
}
@@ -92,7 +93,7 @@ private:
stream = std::ofstream(gdtFilePath, std::fstream::out | std::fstream::binary);
if (!stream.is_open())
{
std::cerr << std::format("Failed to open file for zone definition file of zone \"{}\".\n", zone.m_name);
con::error("Failed to open file for zone definition file of zone \"{}\".", zone.m_name);
return false;
}
@@ -126,16 +127,17 @@ private:
{
if (!handledSpecifiedAssets[i])
{
std::cerr << std::format("Unknown asset type \"{}\"\n", m_args.m_specified_asset_types[i]);
con::error("Unknown asset type \"{}\"", m_args.m_specified_asset_types[i]);
anySpecifiedValueInvalid = true;
}
}
if (anySpecifiedValueInvalid)
{
std::cerr << "Valid asset types are:\n";
con::error("Valid asset types are:");
auto first = true;
std::ostringstream ss;
for (auto i = 0u; i < assetTypeCount; i++)
{
const auto assetTypeName = std::string(*context.m_zone.m_pools->GetAssetTypeName(i));
@@ -143,10 +145,10 @@ private:
if (first)
first = false;
else
std::cerr << ", ";
std::cerr << assetTypeName;
ss << ", ";
ss << assetTypeName;
}
std::cerr << "\n";
con::error(ss.str());
}
}
@@ -207,7 +209,7 @@ private:
if (!result)
{
std::cerr << "Dumping zone failed!\n";
con::error("Dumping zone failed!");
return false;
}
}
@@ -221,7 +223,7 @@ private:
{
if (!fs::is_regular_file(zonePath))
{
std::cerr << std::format("Could not find file \"{}\".\n", zonePath);
con::error("Could not find file \"{}\".", zonePath);
continue;
}
@@ -231,12 +233,11 @@ private:
auto zone = ZoneLoading::LoadZone(zonePath);
if (zone == nullptr)
{
std::cerr << std::format("Failed to load zone \"{}\".\n", zonePath);
con::error("Failed to load zone \"{}\".", zonePath);
return false;
}
if (m_args.m_verbose)
std::cout << std::format("Loaded zone \"{}\"\n", zone->m_name);
con::debug("Loaded zone \"{}\"", zone->m_name);
if (ShouldLoadObj())
{
@@ -267,8 +268,7 @@ private:
loadedZone.reset();
if (m_args.m_verbose)
std::cout << std::format("Unloaded zone \"{}\"\n", zoneName);
con::debug("Unloaded zone \"{}\"", zoneName);
}
m_loaded_zones.clear();
}
@@ -279,7 +279,7 @@ private:
{
if (!fs::is_regular_file(zonePath))
{
std::cerr << std::format("Could not find file \"{}\".\n", zonePath);
con::error("Could not find file \"{}\".", zonePath);
continue;
}
@@ -294,13 +294,12 @@ private:
auto zone = ZoneLoading::LoadZone(zonePath);
if (zone == nullptr)
{
std::cerr << std::format("Failed to load zone \"{}\".\n", zonePath);
con::error("Failed to load zone \"{}\".", zonePath);
return false;
}
zoneName = zone->m_name;
if (m_args.m_verbose)
std::cout << std::format("Loaded zone \"{}\"\n", zoneName);
con::debug("Loaded zone \"{}\"", zoneName);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(zone->m_game_id);
if (ShouldLoadObj())
@@ -313,8 +312,7 @@ private:
objLoader->UnloadContainersOfZone(*zone);
zone.reset();
if (m_args.m_verbose)
std::cout << std::format("Unloaded zone \"{}\"\n", zoneName);
con::debug("Unloaded zone \"{}\"", zoneName);
}
return true;

View File

@@ -5,6 +5,7 @@
#include "ObjWriting.h"
#include "Utils/Arguments/UsageInformation.h"
#include "Utils/FileUtils.h"
#include "Utils/Logging/Log.h"
#include "Utils/StringUtils.h"
#include <format>
@@ -167,7 +168,7 @@ void UnlinkerArgs::PrintUsage() const
void UnlinkerArgs::PrintVersion()
{
std::cout << std::format("OpenAssetTools Unlinker {}\n", GIT_VERSION);
con::info("OpenAssetTools Unlinker {}", GIT_VERSION);
}
void UnlinkerArgs::SetVerbose(const bool isVerbose)
@@ -195,7 +196,7 @@ bool UnlinkerArgs::SetImageDumpingMode() const
}
const std::string originalValue = m_argument_parser.GetValueForOption(OPTION_IMAGE_FORMAT);
std::cerr << std::format("Illegal value: \"{}\" is not a valid image output format. Use -? to see usage information.\n", originalValue);
con::error("Illegal value: \"{}\" is not a valid image output format. Use -? to see usage information.", originalValue);
return false;
}
@@ -235,7 +236,7 @@ bool UnlinkerArgs::SetModelDumpingMode() const
}
const std::string originalValue = m_argument_parser.GetValueForOption(OPTION_MODEL_FORMAT);
std::cerr << std::format("Illegal value: \"{}\" is not a valid model output format. Use -? to see usage information.\n", originalValue);
con::error("Illegal value: \"{}\" is not a valid model output format. Use -? to see usage information.", originalValue);
return false;
}
@@ -358,7 +359,7 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldCont
// --include-assets
if (m_argument_parser.IsOptionSpecified(OPTION_EXCLUDE_ASSETS) && m_argument_parser.IsOptionSpecified(OPTION_INCLUDE_ASSETS))
{
std::cout << "You can only asset types to either exclude or include, not both\n";
con::error("You can only asset types to either exclude or include, not both");
return false;
}

View File

@@ -2,6 +2,7 @@
#include "SearchPath/IWD.h"
#include "SearchPath/SearchPathFilesystem.h"
#include "Utils/Logging/Log.h"
#include "Utils/StringUtils.h"
#include <filesystem>
@@ -18,7 +19,7 @@ bool UnlinkerPaths::LoadUserPaths(const UnlinkerArgs& args)
if (!fs::is_directory(absolutePath))
{
std::cerr << std::format("Could not find directory of search path: \"{}\"\n", path);
con::error("Could not find directory of search path: \"{}\"", path);
return false;
}
@@ -44,12 +45,12 @@ bool UnlinkerPaths::LoadUserPaths(const UnlinkerArgs& args)
}
}
std::cout << std::format("{} SearchPaths{}\n", m_specified_user_paths.size(), !m_specified_user_paths.empty() ? ":" : "");
con::info("{} SearchPaths{}", m_specified_user_paths.size(), !m_specified_user_paths.empty() ? ":" : "");
for (const auto& absoluteSearchPath : m_specified_user_paths)
std::cout << std::format(" \"{}\"\n", absoluteSearchPath);
con::info(" \"{}\"", absoluteSearchPath);
if (!m_specified_user_paths.empty())
std::cerr << "\n";
con::info("");
return true;
}