2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-10-22 06:16:01 +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

@@ -9,6 +9,7 @@
#include "Image/Texture.h"
#include "ObjWriting.h"
#include "SearchPath/ISearchPath.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <cassert>
@@ -43,7 +44,7 @@ namespace
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
std::cerr << std::format("Could not find data for image \"{}\"\n", image.name);
con::error("Could not find data for image \"{}\"", image.name);
return nullptr;
}

View File

@@ -2,6 +2,7 @@
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -38,7 +39,7 @@ namespace localize
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
}
} // namespace localize

View File

@@ -2,6 +2,7 @@
#include "Sound/WavTypes.h"
#include "Sound/WavWriter.h"
#include "Utils/Logging/Log.h"
#include <format>
@@ -45,7 +46,7 @@ namespace sound
break;
default:
std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name);
con::error("Unknown format {} for loaded sound: {}", loadedSound->sound.info.format, loadedSound->name);
break;
}
}

View File

@@ -6,6 +6,7 @@
#include "Image/IwiLoader.h"
#include "Image/IwiWriter8.h"
#include "ObjWriting.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <cassert>
@@ -40,7 +41,7 @@ namespace
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
std::cerr << std::format("Could not find data for image \"{}\"\n", image.name);
con::error("Could not find data for image \"{}\"", image.name);
return nullptr;
}

View File

@@ -2,6 +2,7 @@
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <sstream>
@@ -38,7 +39,7 @@ namespace localize
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
}
} // namespace localize

View File

@@ -4,6 +4,7 @@
#include "Game/IW4/ObjConstantsIW4.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "Utils/ClassUtils.h"
#include "Utils/Logging/Log.h"
#pragma warning(push, 0)
#include <Eigen>
@@ -550,7 +551,7 @@ namespace
}
else
{
std::cout << "Could not determine material type for material \"" << m_material.info.name << "\"\n";
con::error("Could not determine material type for material \"{}\"", m_material.info.name);
}
}
@@ -937,7 +938,7 @@ namespace
else
{
std::string constantNamePart(constant.name, strnlen(constant.name, std::extent_v<decltype(constant.name)>));
std::cout << "Unknown constant: " << constantNamePart << "\n";
con::error("Unknown constant: {}", constantNamePart);
}
}
}
@@ -1031,8 +1032,7 @@ namespace
if (knownMaterialSourceName == knownTextureMaps.end())
{
assert(false);
std::cout << "Unknown material texture source name hash: 0x" << std::hex << entry.nameHash << " (" << entry.nameStart << "..."
<< entry.nameEnd << ")\n";
con::error("Unknown material texture source name hash: 0x{:x} ({}...{})", entry.nameHash, entry.nameStart, entry.nameEnd);
continue;
}
@@ -1089,7 +1089,7 @@ namespace
assert(filter != GdtFilter_e::UNKNOWN);
if (filter == GdtFilter_e::UNKNOWN)
{
std::cout << std::format("Unknown filter/mipmap combination: {} {}\n", entry.samplerState.filter, entry.samplerState.mipMap);
con::warn("Unknown filter/mipmap combination: {} {}", entry.samplerState.filter, entry.samplerState.mipMap);
continue;
}

View File

@@ -1,5 +1,7 @@
#include "RawFileDumperIW4.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <stdexcept>
#include <zlib.h>
@@ -52,7 +54,7 @@ namespace raw_file
if (ret < 0)
{
std::cerr << std::format("Inflate failed when attempting to dump rawfile '{}'\n", rawFile->name);
con::error("Inflate failed when attempting to dump rawfile '{}'", rawFile->name);
inflateEnd(&zs);
return;
}

View File

@@ -2,6 +2,7 @@
#include "Sound/WavTypes.h"
#include "Sound/WavWriter.h"
#include "Utils/Logging/Log.h"
#include <format>
@@ -45,7 +46,7 @@ namespace sound
break;
default:
std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name);
con::error("Unknown format {} for loaded sound: {}", loadedSound->sound.info.format, loadedSound->name);
break;
}
}

View File

@@ -5,9 +5,11 @@
#include "Pool/GlobalAssetPool.h"
#include "Shader/D3D9ShaderAnalyser.h"
#include "Techset/TechsetCommon.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <cassert>
#include <format>
#include <set>
#include <sstream>
#include <type_traits>
@@ -266,8 +268,8 @@ namespace IW4
{
// Cannot dump when shader is referenced due to unknown constant names and unknown version
Indent();
std::cerr << "Cannot dump vertex shader " << &vertexShader->name[1] << " due to being a referenced asset\n";
m_stream << "// Cannot dump vertex shader " << &vertexShader->name[1] << " due to being a referenced asset\n";
con::error("Cannot dump vertex shader {} due to being a referenced asset", &vertexShader->name[1]);
m_stream << std::format("// Cannot dump vertex shader {} due to being a referenced asset\n", &vertexShader->name[1]);
return;
}
vertexShader = loadedVertexShaderFromOtherZone->Asset();
@@ -321,8 +323,8 @@ namespace IW4
{
// Cannot dump when shader is referenced due to unknown constant names and unknown version
Indent();
std::cerr << "Cannot dump pixel shader " << &pixelShader->name[1] << " due to being a referenced asset\n";
m_stream << "// Cannot dump pixel shader " << &pixelShader->name[1] << " due to being a referenced asset\n";
con::error("Cannot dump pixel shader {} due to being a referenced asset", &pixelShader->name[1]);
m_stream << std::format("// Cannot dump pixel shader {} due to being a referenced asset\n", &pixelShader->name[1]);
return;
}
pixelShader = loadedPixelShaderFromOtherZone->Asset();
@@ -393,8 +395,8 @@ namespace IW4
{
// Cannot dump when shader is referenced due to unknown constant names and unknown version
Indent();
std::cerr << "Cannot dump vertex decl " << &vertexDecl->name[1] << " due to being a referenced asset\n";
m_stream << "// Cannot dump vertex decl " << &vertexDecl->name[1] << " due to being a referenced asset\n";
con::error("Cannot dump vertex decl {} due to being a referenced asset", &vertexDecl->name[1]);
m_stream << std::format("// Cannot dump vertex decl {} due to being a referenced asset\n", &vertexDecl->name[1]);
return;
}
vertexDecl = loadedVertexDeclFromOtherZone->Asset();

View File

@@ -6,6 +6,7 @@
#include "Image/IwiLoader.h"
#include "Image/IwiWriter8.h"
#include "ObjWriting.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <cassert>
@@ -41,7 +42,7 @@ namespace
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
std::cerr << std::format("Could not find data for image \"{}\"\n", image.name);
con::error("Could not find data for image \"{}\"", image.name);
return nullptr;
}

View File

@@ -2,6 +2,7 @@
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -38,7 +39,7 @@ namespace localize
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
}
} // namespace localize

View File

@@ -1,5 +1,7 @@
#include "RawFileDumperIW5.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <stdexcept>
#include <zlib.h>
@@ -52,7 +54,7 @@ namespace raw_file
if (ret < 0)
{
std::cerr << std::format("Inflate failed when attempting to dump rawfile '{}'\n", rawFile->name);
con::error("Inflate failed when attempting to dump rawfile '{}'", rawFile->name);
inflateEnd(&zs);
return;
}

View File

@@ -2,6 +2,7 @@
#include "Sound/WavTypes.h"
#include "Sound/WavWriter.h"
#include "Utils/Logging/Log.h"
#include <format>
@@ -45,7 +46,7 @@ namespace sound
break;
default:
std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name);
con::error("Unknown format {} for loaded sound: {}", loadedSound->sound.info.format, loadedSound->name);
break;
}
}

View File

@@ -6,6 +6,7 @@
#include "Image/IwiLoader.h"
#include "Image/IwiWriter13.h"
#include "ObjWriting.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <cassert>
@@ -40,7 +41,7 @@ namespace
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
std::cerr << std::format("Could not find data for image \"{}\"\n", image.name);
con::error("Could not find data for image \"{}\"", image.name);
return nullptr;
}

View File

@@ -2,6 +2,7 @@
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -38,7 +39,7 @@ namespace localize
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
}
} // namespace localize

View File

@@ -1,5 +1,6 @@
#include "RawFileDumperT5.h"
#include "Utils/Logging/Log.h"
#include "Utils/StringUtils.h"
#include <cassert>
@@ -20,7 +21,7 @@ namespace
if (rawFile->len <= 8)
{
std::cout << "Invalid len of gsc file \"" << rawFile->name << "\"\n";
con::error("Invalid len of gsc file \"{}\"", rawFile->name);
return;
}
@@ -31,13 +32,13 @@ namespace
if (inLen > static_cast<unsigned>(rawFile->len - 8) + 1)
{
std::cout << "Invalid compression of gsc file \"" << rawFile->name << "\": " << inLen << "\n";
con::error("Invalid compression of gsc file \"{}\": {}", rawFile->name, inLen);
return;
}
if (outLen > GSC_MAX_SIZE)
{
std::cout << "Invalid size of gsc file \"" << rawFile->name << "\": " << outLen << "\n";
con::error("Invalid size of gsc file \"{}\": {}", rawFile->name, outLen);
return;
}
@@ -70,7 +71,7 @@ namespace
if (ret < 0)
{
std::cout << "Inflate failed for dumping gsc file \"" << rawFile->name << "\"\n";
con::error("Inflate failed for dumping gsc file \"{}\"", rawFile->name);
inflateEnd(&zs);
return;
}

View File

@@ -7,6 +7,7 @@
#include "Image/IwiWriter27.h"
#include "ObjContainer/IPak/IPak.h"
#include "ObjWriting.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <cassert>
@@ -58,7 +59,7 @@ namespace
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
std::cerr << std::format("Could not find data for image \"{}\"\n", image.name);
con::error("Could not find data for image \"{}\"", image.name);
return nullptr;
}

View File

@@ -2,6 +2,7 @@
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -38,7 +39,7 @@ namespace localize
}
else
{
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
con::error("Could not create string file for dumping localized strings of zone '{}'", context.m_zone.m_name);
}
}
} // namespace localize

View File

@@ -1,5 +1,7 @@
#include "RawFileDumperT6.h"
#include "Utils/Logging/Log.h"
#include <filesystem>
#include <zlib.h>
#include <zutil.h>
@@ -18,7 +20,7 @@ namespace
if (rawFile->len <= 4)
{
std::cerr << "Invalid len of animtree file \"" << rawFile->name << "\"\n";
con::error("Invalid len of animtree file \"{}\"", rawFile->name);
return;
}
@@ -27,7 +29,7 @@ namespace
if (outLen > ANIMTREE_MAX_SIZE)
{
std::cerr << "Invalid size of animtree file \"" << rawFile->name << "\": " << outLen << "\n";
con::error("Invalid size of animtree file \"{}\": {}", rawFile->name, outLen);
return;
}
@@ -59,7 +61,7 @@ namespace
if (ret < 0)
{
std::cerr << "Inflate failed for dumping animtree file \"" << rawFile->name << "\"\n";
con::error("Inflate failed for dumping animtree file \"{}\"", rawFile->name);
inflateEnd(&zs);
return;
}

View File

@@ -7,6 +7,7 @@
#include "Game/T6/SoundConstantsT6.h"
#include "ObjContainer/SoundBank/SoundBank.h"
#include "Sound/WavWriter.h"
#include "Utils/Logging/Log.h"
#include "Zone/ZoneRegistry.h"
#include <algorithm>
@@ -670,7 +671,7 @@ namespace
const auto outFile = OpenAssetOutputFile(context, assetFileName, ".wav");
if (!outFile)
{
std::cerr << std::format("Failed to open sound output file: \"{}\"\n", assetFileName);
con::error("Failed to open sound output file: \"{}\"", assetFileName);
return;
}
@@ -700,7 +701,7 @@ namespace
const auto outFile = OpenAssetOutputFile(context, assetFileName, extension);
if (!outFile)
{
std::cerr << std::format("Failed to open sound output file: \"{}\"\n", assetFileName);
con::error("Failed to open sound output file: \"{}\"", assetFileName);
return;
}
@@ -737,19 +738,19 @@ namespace
case SND_ASSET_FORMAT_WMA:
case SND_ASSET_FORMAT_WIIUADPCM:
case SND_ASSET_FORMAT_MPC:
std::cerr << std::format("Cannot dump sound (Unknown sound format {}): \"{}\"\n", static_cast<unsigned>(format), alias.assetFileName);
con::error("Cannot dump sound (Unknown sound format {}): \"{}\"", static_cast<unsigned>(format), alias.assetFileName);
break;
default:
assert(false);
std::cerr << std::format("Cannot dump sound (Unknown sound format {}): \"{}\"\n", static_cast<unsigned>(format), alias.assetFileName);
con::error("Cannot dump sound (Unknown sound format {}): \"{}\"", static_cast<unsigned>(format), alias.assetFileName);
break;
}
return format;
}
std::cerr << std::format("Could not find data for sound \"{}\"\n", alias.assetFileName);
con::warn("Could not find data for sound \"{}\"", alias.assetFileName);
return {};
}
@@ -760,7 +761,7 @@ namespace
const auto outFile = OpenAssetOutputFile(context, std::format("soundbank/{}.aliases", sndBank.name), ".csv");
if (!outFile)
{
std::cerr << std::format("Failed to open sound alias output file: \"\"\n", sndBank.name);
con::error("Failed to open sound alias output file: \"\"", sndBank.name);
return;
}
@@ -804,7 +805,7 @@ namespace
const auto outFile = OpenAssetOutputFile(context, std::format("soundbank/{}.reverbs", sndBank.name), ".csv");
if (!outFile)
{
std::cerr << std::format("Failed to open sound reverb output file: \"{}\"\n", sndBank.name);
con::error("Failed to open sound reverb output file: \"{}\"", sndBank.name);
return;
}
@@ -843,7 +844,7 @@ namespace
const auto outFile = OpenAssetOutputFile(context, std::format("soundbank/{}.ducklist", sndBank.name), ".csv");
if (!outFile)
{
std::cerr << std::format("Failed to open sound reverb output file: \"{}\"\n", sndBank.name);
con::error("Failed to open sound reverb output file: \"{}\"", sndBank.name);
return;
}
@@ -860,7 +861,7 @@ namespace
const auto duckFile = OpenAssetOutputFile(context, std::format("soundbank/ducks/{}", duck.name), ".duk");
if (!outFile)
{
std::cerr << std::format("Failed to open sound duck output file: \"{}\"\n", duck.name);
con::error("Failed to open sound duck output file: \"{}\"", duck.name);
return;
}

View File

@@ -2,6 +2,7 @@
#include "Csv/CsvStream.h"
#include "ObjContainer/SoundBank/SoundBank.h"
#include "Utils/Logging/Log.h"
#include <format>
@@ -123,7 +124,7 @@ namespace
{
auto outputFile = this->m_context.OpenAssetFile(filename);
if (outputFile == nullptr)
std::cerr << std::format("Failed to open sound driver globals output file for: \"{}\"\n", filename);
con::error("Failed to open sound driver globals output file for: \"{}\"", filename);
return outputFile;
}

View File

@@ -3,6 +3,7 @@
#include "ObjWriting.h"
#include "Shader/D3D11ShaderAnalyser.h"
#include "Shader/D3D9ShaderAnalyser.h"
#include "Utils/Logging/Log.h"
#include <chrono>
@@ -15,8 +16,7 @@ namespace
void AbstractMaterialConstantZoneState::ExtractNamesFromZone()
{
if (ObjWriting::Configuration.Verbose)
std::cout << "Building material constant name lookup...\n";
con::debug("Building material constant name lookup...");
const auto begin = std::chrono::high_resolution_clock::now();
@@ -29,10 +29,10 @@ void AbstractMaterialConstantZoneState::ExtractNamesFromZone()
if (ObjWriting::Configuration.Verbose)
{
const auto durationInMs = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
std::cout << std::format("Built material constant name lookup in {}ms: {} constant names; {} texture def names\n",
durationInMs.count(),
m_constant_names_from_shaders.size(),
m_texture_def_names_from_shaders.size());
con::debug("Built material constant name lookup in {}ms: {} constant names; {} texture def names",
durationInMs.count(),
m_constant_names_from_shaders.size(),
m_texture_def_names_from_shaders.size());
}
}

View File

@@ -1,5 +1,7 @@
#include "AccuracyGraphWriter.h"
#include "Utils/Logging/Log.h"
#include <format>
namespace
@@ -24,7 +26,7 @@ namespace
const auto file = context.OpenAssetFile(std::format("accuracy/{}/{}", subFolder, graph.name));
if (!file)
{
std::cerr << "Failed to open file for accuracy graph: " << subFolder << "/" << graph.name << "\n";
con::error("Failed to open file for accuracy graph: {}/{}", subFolder, graph.name);
return;
}