From 02f20f09b6af76ead22802a313f658ea344994d2 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 10 Sep 2025 19:52:42 +0200 Subject: [PATCH] chore: update all logging to use centralized logging component --- src/ImageConverter/ImageConverter.cpp | 25 ++--- src/ImageConverter/ImageConverterArgs.cpp | 3 +- src/Linker/Linker.cpp | 39 ++++---- src/Linker/LinkerArgs.cpp | 3 +- src/Linker/LinkerPaths.cpp | 5 +- src/ObjCommon/InfoString/InfoString.cpp | 12 ++- src/ObjCommon/Obj/Gdt/GdtStream.cpp | 4 +- .../SearchPath/OutputPathFilesystem.cpp | 6 +- .../SearchPath/SearchPathFilesystem.cpp | 3 +- src/ObjCommon/Sound/FlacDecoder.cpp | 3 +- .../Game/IW4/Material/CompilerMaterialIW4.cpp | 5 +- .../Game/IW4/Techset/CompilerTechsetIW4.cpp | 3 +- .../IW4/Techset/CompilerVertexDeclIW4.cpp | 9 +- src/ObjCompiling/Image/IPak/IPakCreator.cpp | 7 +- src/ObjCompiling/Iwd/IwdCreator.cpp | 11 ++- .../KeyValuePairs/KeyValuePairsCreator.cpp | 4 +- src/ObjImage/Image/DdsLoader.cpp | 20 ++-- src/ObjImage/Image/IwiLoader.cpp | 41 ++++---- src/ObjLoading/Asset/AssetCreationContext.cpp | 16 +-- .../Game/IW3/Image/AssetLoaderImageIW3.cpp | 3 +- .../Game/IW3/Material/LoaderMaterialIW3.cpp | 3 +- .../InfoStringToStructConverter.cpp | 14 +-- .../IW4/Leaderboard/LoaderLeaderboardIW4.cpp | 7 +- .../Game/IW4/LightDef/LightDefLoaderIW4.cpp | 3 +- .../Game/IW4/Material/LoaderMaterialIW4.cpp | 3 +- .../Game/IW4/Menu/LoaderMenuListIW4.cpp | 23 ++--- .../IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp | 3 +- .../InfoStringLoaderPhysPresetIW4.cpp | 3 +- .../IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp | 3 +- .../Game/IW4/RawFile/LoaderRawFileIW4.cpp | 3 +- .../Game/IW4/Shader/LoaderPixelShaderIW4.cpp | 3 +- .../Game/IW4/Shader/LoaderVertexShaderIW4.cpp | 3 +- .../Game/IW4/Sound/LoaderSoundCurveIW4.cpp | 3 +- .../Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp | 3 +- .../IW4/Weapon/InfoStringLoaderWeaponIW4.cpp | 66 ++++++------- .../Game/IW4/Weapon/RawLoaderWeaponIW4.cpp | 3 +- .../Game/IW5/Image/LoaderImageIW5.cpp | 3 +- .../InfoStringToStructConverter.cpp | 14 +-- .../IW5/Leaderboard/LoaderLeaderboardIW5.cpp | 7 +- .../Game/IW5/Material/LoaderMaterialIW5.cpp | 3 +- .../Game/IW5/Menu/LoaderMenuListIW5.cpp | 23 ++--- .../Game/IW5/RawFile/LoaderRawFileIW5.cpp | 3 +- .../Game/IW5/Script/LoaderScriptFileIW5.cpp | 5 +- .../Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp | 3 +- .../IW5/Weapon/InfoStringLoaderWeaponIW5.cpp | 98 +++++++++---------- .../Game/IW5/Weapon/LoaderAttachmentIW5.cpp | 9 +- .../Game/IW5/Weapon/RawLoaderWeaponIW5.cpp | 3 +- .../Game/T5/Material/LoaderMaterialT5.cpp | 3 +- .../Game/T5/RawFile/LoaderRawFileT5.cpp | 3 +- .../Game/T6/FontIcon/CsvLoaderFontIconT6.cpp | 21 ++-- .../Game/T6/FontIcon/JsonLoaderFontIconT6.cpp | 7 +- .../Game/T6/Image/LoaderImageT6.cpp | 3 +- .../InfoStringToStructConverter.cpp | 13 +-- .../Leaderboard/JsonLoaderLeaderboardT6.cpp | 7 +- .../Game/T6/Material/LoaderMaterialT6.cpp | 3 +- src/ObjLoading/Game/T6/ObjLoaderT6.cpp | 39 +++----- .../GdtLoaderPhysConstraintsT6.cpp | 3 +- .../InfoStringLoaderPhysConstraintsT6.cpp | 3 +- .../RawLoaderPhysConstraintsT6.cpp | 3 +- .../T6/PhysPreset/GdtLoaderPhysPresetT6.cpp | 3 +- .../InfoStringLoaderPhysPresetT6.cpp | 3 +- .../T6/PhysPreset/RawLoaderPhysPresetT6.cpp | 3 +- .../Game/T6/RawFile/LoaderRawFileT6.cpp | 3 +- .../Game/T6/Sound/LoaderSoundBankT6.cpp | 53 +++++----- .../Game/T6/Tracer/GdtLoaderTracerT6.cpp | 3 +- .../T6/Tracer/InfoStringLoaderTracerT6.cpp | 3 +- .../Game/T6/Tracer/RawLoaderTracerT6.cpp | 3 +- .../Game/T6/Vehicle/GdtLoaderVehicleT6.cpp | 3 +- .../T6/Vehicle/InfoStringLoaderVehicleT6.cpp | 9 +- .../Game/T6/Vehicle/RawLoaderVehicleT6.cpp | 3 +- .../Game/T6/Weapon/AttachmentGdtLoaderT6.cpp | 3 +- .../Weapon/AttachmentInfoStringLoaderT6.cpp | 3 +- .../Game/T6/Weapon/AttachmentRawLoaderT6.cpp | 3 +- .../T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp | 3 +- .../AttachmentUniqueInfoStringLoaderT6.cpp | 11 ++- .../T6/Weapon/AttachmentUniqueRawLoaderT6.cpp | 3 +- .../Game/T6/Weapon/CamoJsonLoaderT6.cpp | 9 +- .../Game/T6/Weapon/WeaponGdtLoaderT6.cpp | 3 +- .../T6/Weapon/WeaponInfoStringLoaderT6.cpp | 52 +++++----- .../Game/T6/Weapon/WeaponRawLoaderT6.cpp | 3 +- .../Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp | 3 +- .../ZBarrier/InfoStringLoaderZBarrierT6.cpp | 3 +- .../Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp | 3 +- .../InfoStringToStructConverterBase.cpp | 17 ++-- .../InfoStringToStructConverterBase.h | 7 +- .../Localize/Parsing/LocalizeFileReader.cpp | 3 +- .../SequenceLocalizeFileLanguageValue.cpp | 9 +- .../Material/JsonMaterialLoader.cpp.template | 9 +- src/ObjLoading/Menu/AbstractMenuConverter.cpp | 10 +- src/ObjLoading/ObjContainer/IPak/IPak.cpp | 17 ++-- .../ObjContainer/IPak/IPakEntryReadStream.cpp | 9 +- .../ObjContainer/SoundBank/SoundBank.cpp | 25 ++--- .../SoundBank/SoundBankWriter.cpp | 12 +-- .../Parsing/Graph2D/Graph2DReader.cpp | 13 +-- .../Parsing/Menu/MenuFileReader.cpp | 13 +-- src/ObjLoading/SearchPath/IWD.cpp | 7 +- src/ObjLoading/StateMap/StateMapHandler.cpp | 4 +- src/ObjLoading/StateMap/StateMapReader.cpp | 9 +- .../StructuredDataDefReader.cpp | 3 +- .../Techset/TechniqueFileReader.cpp | 3 +- src/ObjLoading/Techset/TechsetFileReader.cpp | 3 +- src/ObjLoading/Weapon/AccuracyGraphLoader.cpp | 3 +- src/ObjLoading/XModel/Gltf/GltfBinInput.cpp | 11 ++- src/ObjLoading/XModel/Gltf/GltfLoader.cpp | 5 +- src/ObjLoading/XModel/Gltf/GltfTextInput.cpp | 4 +- .../XModel/LoaderXModel.cpp.template | 17 ++-- .../XModel/PartClassificationState.cpp | 10 +- .../Game/IW3/Image/ImageDumperIW3.cpp | 3 +- .../Game/IW3/Localize/LocalizeDumperIW3.cpp | 3 +- .../Game/IW3/Sound/LoadedSoundDumperIW3.cpp | 3 +- .../Game/IW4/Image/ImageDumperIW4.cpp | 3 +- .../Game/IW4/Localize/LocalizeDumperIW4.cpp | 3 +- .../Material/MaterialDecompilingDumperIW4.cpp | 10 +- .../Game/IW4/RawFile/RawFileDumperIW4.cpp | 4 +- .../Game/IW4/Sound/LoadedSoundDumperIW4.cpp | 3 +- .../Game/IW4/Techset/TechsetDumperIW4.cpp | 14 +-- .../Game/IW5/Image/ImageDumperIW5.cpp | 3 +- .../Game/IW5/Localize/LocalizeDumperIW5.cpp | 3 +- .../Game/IW5/RawFile/RawFileDumperIW5.cpp | 4 +- .../Game/IW5/Sound/LoadedSoundDumperIW5.cpp | 3 +- .../Game/T5/Image/ImageDumperT5.cpp | 3 +- .../Game/T5/Localize/LocalizeDumperT5.cpp | 3 +- .../Game/T5/RawFile/RawFileDumperT5.cpp | 9 +- .../Game/T6/Image/ImageDumperT6.cpp | 3 +- .../Game/T6/Localize/LocalizeDumperT6.cpp | 3 +- .../Game/T6/RawFile/RawFileDumperT6.cpp | 8 +- .../Game/T6/Sound/SndBankDumperT6.cpp | 19 ++-- .../T6/Sound/SndDriverGlobalsDumperT6.cpp | 3 +- .../AbstractMaterialConstantZoneState.cpp | 12 +-- src/ObjWriting/Weapon/AccuracyGraphWriter.cpp | 4 +- src/Parser/Parsing/Impl/AbstractParser.h | 11 ++- src/RawTemplater/RawTemplater.cpp | 5 +- src/RawTemplater/RawTemplaterArguments.cpp | 3 +- src/RawTemplater/Templating/Templater.cpp | 15 +-- src/Unlinker/ContentLister/ContentPrinter.cpp | 10 +- src/Unlinker/Unlinker.cpp | 38 ++++--- src/Unlinker/UnlinkerArgs.cpp | 9 +- src/Unlinker/UnlinkerPaths.cpp | 9 +- src/Utils/Utils/Arguments/ArgumentParser.cpp | 9 +- .../Utils/Arguments/UsageInformation.cpp | 4 +- src/Utils/Utils/Logging/Log.h | 43 ++++++-- .../Generating/CodeGenerator.cpp | 20 ++-- .../Parsing/Commands/CommandsFileReader.cpp | 11 +-- .../Parsing/Header/HeaderFileReader.cpp | 9 +- .../Parsing/Header/Impl/HeaderParserState.cpp | 3 +- .../CalculateSizeAndAlignPostProcessor.cpp | 18 ++-- .../PostProcessing/UnionsPostProcessor.cpp | 4 +- .../ZoneCodeGeneratorArguments.cpp | 9 +- .../Zone/AssetList/AssetListReader.cpp | 5 +- .../SequenceZoneDefinitionMetaData.cpp | 11 ++- .../Zone/Definition/ZoneDefinitionStream.cpp | 5 +- .../Zone/XChunk/XChunkProcessorInflate.cpp | 3 +- .../XChunk/XChunkProcessorLzxDecompress.cpp | 12 ++- .../Game/IW4/ZoneLoaderFactoryIW4.cpp | 3 +- .../Game/IW5/ZoneLoaderFactoryIW5.cpp | 3 +- .../Game/T6/ZoneLoaderFactoryT6.cpp | 5 +- src/ZoneLoading/Loading/ZoneLoader.cpp | 3 +- .../Zone/Stream/ZoneInputStream.cpp | 4 +- src/ZoneLoading/ZoneLoading.cpp | 7 +- src/ZoneWriting/Writing/ZoneWriter.cpp | 5 +- src/ZoneWriting/ZoneWriting.cpp | 5 +- 161 files changed, 824 insertions(+), 664 deletions(-) diff --git a/src/ImageConverter/ImageConverter.cpp b/src/ImageConverter/ImageConverter.cpp index 7f180876..22fa6090 100644 --- a/src/ImageConverter/ImageConverter.cpp +++ b/src/ImageConverter/ImageConverter.cpp @@ -9,6 +9,7 @@ #include "Image/IwiWriter8.h" #include "Image/Texture.h" #include "ImageConverterArgs.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -61,7 +62,7 @@ namespace image_converter else if (extension == EXTENSION_DDS) ConvertDds(filePath); else - std::cerr << std::format("Unsupported extension {}\n", extension); + con::error("Unsupported extension {}", extension); } bool ConvertIwi(const fs::path& iwiPath) @@ -69,7 +70,7 @@ namespace image_converter std::ifstream file(iwiPath, std::ios::in | std::ios::binary); if (!file.is_open()) { - std::cerr << std::format("Failed to open input file {}\n", iwiPath.string()); + con::error("Failed to open input file {}", iwiPath.string()); return false; } @@ -83,7 +84,7 @@ namespace image_converter std::ofstream outFile(outPath, std::ios::out | std::ios::binary); if (!outFile.is_open()) { - std::cerr << std::format("Failed to open output file {}\n", outPath.string()); + con::error("Failed to open output file {}", outPath.string()); return false; } @@ -96,7 +97,7 @@ namespace image_converter std::ifstream file(ddsPath, std::ios::in | std::ios::binary); if (!file.is_open()) { - std::cerr << std::format("Failed to open input file {}\n", ddsPath.string()); + con::error("Failed to open input file {}", ddsPath.string()); return false; } @@ -113,7 +114,7 @@ namespace image_converter std::ofstream outFile(outPath, std::ios::out | std::ios::binary); if (!outFile.is_open()) { - std::cerr << std::format("Failed to open output file {}\n", outPath.string()); + con::error("Failed to open output file {}", outPath.string()); return false; } @@ -154,12 +155,12 @@ namespace image_converter bool ShowGameTui() { - std::cout << "Select the game to convert to:\n"; - std::cout << " 1 - Call Of Duty 4: Modern Warfare (IW3)\n"; - std::cout << " 2 - Call Of Duty: Modern Warfare 2 (IW4)\n"; - std::cout << " 3 - Call Of Duty: Modern Warfare 3 (IW5)\n"; - std::cout << " 4 - Call Of Duty: Black Ops (T5)\n"; - std::cout << " 5 - Call Of Duty: Black Ops 2 (T6)\n"; + con::info("Select the game to convert to:"); + con::info(" 1 - Call Of Duty 4: Modern Warfare (IW3)"); + con::info(" 2 - Call Of Duty: Modern Warfare 2 (IW4)"); + con::info(" 3 - Call Of Duty: Modern Warfare 3 (IW5)"); + con::info(" 4 - Call Of Duty: Black Ops (T5)"); + con::info(" 5 - Call Of Duty: Black Ops 2 (T6)"); unsigned num; std::cin >> num; @@ -182,7 +183,7 @@ namespace image_converter m_game_to_convert_to = Game::T6; break; default: - std::cerr << "Invalid input\n"; + con::error("Invalid input"); return false; } diff --git a/src/ImageConverter/ImageConverterArgs.cpp b/src/ImageConverter/ImageConverterArgs.cpp index 8b51a46f..653f4625 100644 --- a/src/ImageConverter/ImageConverterArgs.cpp +++ b/src/ImageConverter/ImageConverterArgs.cpp @@ -2,6 +2,7 @@ #include "GitVersion.h" #include "Utils/Arguments/UsageInformation.h" +#include "Utils/Logging/Log.h" #include #include @@ -101,7 +102,7 @@ void ImageConverterArgs::PrintUsage() void ImageConverterArgs::PrintVersion() { - std::cout << std::format("OpenAssetTools ImageConverter {}\n", GIT_VERSION); + con::info("OpenAssetTools ImageConverter {}", GIT_VERSION); } void ImageConverterArgs::SetVerbose(const bool isVerbose) diff --git a/src/Linker/Linker.cpp b/src/Linker/Linker.cpp index 941f639c..61050cf0 100644 --- a/src/Linker/Linker.cpp +++ b/src/Linker/Linker.cpp @@ -6,6 +6,7 @@ #include "ObjWriting.h" #include "SearchPath/OutputPathFilesystem.h" #include "SearchPath/SearchPaths.h" +#include "Utils/Logging/Log.h" #include "Utils/ObjFileStream.h" #include "Zone/AssetList/AssetList.h" #include "Zone/AssetList/AssetListReader.h" @@ -165,7 +166,7 @@ class LinkerImpl final : public Linker if (!definitionStream.IsOpen()) { if (logMissing) - std::cerr << std::format("Could not find zone definition file for target \"{}\".\n", targetName); + con::error("Could not find zone definition file for target \"{}\".", targetName); return nullptr; } @@ -175,7 +176,7 @@ class LinkerImpl final : public Linker if (!zoneDefinition) { - std::cerr << std::format("Failed to read zone definition file for target \"{}\".\n", targetName); + con::error("Failed to read zone definition file for target \"{}\".", targetName); return nullptr; } @@ -225,7 +226,7 @@ class LinkerImpl final : public Linker if (!ReadIgnoreEntries(paths, ignore, context.m_definition->m_game, context.m_ignored_assets)) { - std::cerr << std::format("Failed to read asset listing for ignoring assets of project \"{}\".\n", ignore); + con::error("Failed to read asset listing for ignoring assets of project \"{}\".", ignore); return false; } } @@ -239,7 +240,7 @@ class LinkerImpl final : public Linker const auto gdtFile = gdtSearchPath->Open(std::format("{}.gdt", gdtName)); if (!gdtFile.IsOpen()) { - std::cerr << std::format("Failed to open file for gdt \"{}\"\n", gdtName); + con::error("Failed to open file for gdt \"{}\"", gdtName); return false; } @@ -247,7 +248,7 @@ class LinkerImpl final : public Linker auto gdt = std::make_unique(); if (!gdtReader.Read(*gdt)) { - std::cerr << std::format("Failed to read gdt file \"{}\"\n", gdtName); + con::error("Failed to read gdt file \"{}\"", gdtName); return false; } @@ -274,19 +275,19 @@ class LinkerImpl final : public Linker const auto stream = outPath.Open(std::format("{}.ff", zone.m_name)); if (!stream) { - std::cerr << std::format("Failed to open file for zone: {}\n", zone.m_name); + con::error("Failed to open file for zone: {}", zone.m_name); return false; } - std::cout << std::format("Building zone \"{}\"\n", zone.m_name); + con::info("Building zone \"{}\"", zone.m_name); if (!ZoneWriting::WriteZone(*stream, zone)) { - std::cerr << "Writing zone failed.\n"; + con::error("Writing zone failed."); return false; } - std::cout << std::format("Created zone \"{}\"\n", zone.m_name); + con::info("Created zone \"{}\"", zone.m_name); return true; } @@ -339,7 +340,7 @@ class LinkerImpl final : public Linker if (alreadyBuiltTargets.find(referencedTarget) == alreadyBuiltTargets.end()) { targetsToBuild.emplace_back(referencedTarget); - std::cout << std::format("Building referenced target \"{}\"\n", referencedTarget); + con::info("Building referenced target \"{}\"", referencedTarget); } } } @@ -354,7 +355,7 @@ class LinkerImpl final : public Linker { if (!fs::is_regular_file(zonePath)) { - std::cerr << std::format("Could not find zone file to load \"{}\".\n", zonePath); + con::error("Could not find zone file to load \"{}\".", zonePath); return false; } @@ -366,14 +367,11 @@ class LinkerImpl final : public Linker auto zone = ZoneLoading::LoadZone(zonePath); if (!zone) { - 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("Load zone \"{}\"\n", zone->m_name); - } + con::debug("Load zone \"{}\"", zone->m_name); m_loaded_zones.emplace_back(std::move(zone)); } @@ -390,8 +388,7 @@ class LinkerImpl final : public Linker loadedZone.reset(); - if (m_args.m_verbose) - std::cout << std::format("Unloaded zone \"{}\"\n", zoneName); + con::debug("Unloaded zone \"{}\"", zoneName); } m_loaded_zones.clear(); } @@ -406,7 +403,7 @@ class LinkerImpl final : public Linker } else if (projectSpecifier.find_first_of('/', targetNameSeparatorIndex + 1) != std::string::npos) { - std::cerr << std::format("Project specifier cannot have more than one target name: \"{}\"\n", projectSpecifier); + con::error("Project specifier cannot have more than one target name: \"{}\"", projectSpecifier); return false; } else @@ -417,13 +414,13 @@ class LinkerImpl final : public Linker if (projectName.empty()) { - std::cerr << std::format("Project name cannot be empty: \"{}\"\n", projectSpecifier); + con::error("Project name cannot be empty: \"{}\"", projectSpecifier); return false; } if (targetName.empty()) { - std::cerr << std::format("Target name cannot be empty: \"{}\"\n", projectSpecifier); + con::error("Target name cannot be empty: \"{}\"", projectSpecifier); return false; } diff --git a/src/Linker/LinkerArgs.cpp b/src/Linker/LinkerArgs.cpp index 30f3ff14..76abd41b 100644 --- a/src/Linker/LinkerArgs.cpp +++ b/src/Linker/LinkerArgs.cpp @@ -5,6 +5,7 @@ #include "ObjWriting.h" #include "Utils/Arguments/UsageInformation.h" #include "Utils/FileUtils.h" +#include "Utils/Logging/Log.h" #include "Utils/PathUtils.h" #include @@ -150,7 +151,7 @@ void LinkerArgs::PrintUsage() const void LinkerArgs::PrintVersion() { - std::cout << std::format("OpenAssetTools Linker {}\n", GIT_VERSION); + con::info("OpenAssetTools Linker {}", GIT_VERSION); } void LinkerArgs::SetBinFolder() diff --git a/src/Linker/LinkerPaths.cpp b/src/Linker/LinkerPaths.cpp index 37631e49..30fea265 100644 --- a/src/Linker/LinkerPaths.cpp +++ b/src/Linker/LinkerPaths.cpp @@ -3,6 +3,7 @@ #include "SearchPath/IWD.h" #include "SearchPath/SearchPathFilesystem.h" #include "SearchPath/SearchPaths.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -241,11 +242,11 @@ namespace if (!fs::is_directory(path)) { - std::cout << std::format("Adding {} search path (Not found): {}\n", m_type_name, path); + con::debug("Adding {} search path (Not found): {}", m_type_name, path); return false; } - std::cout << std::format("Adding {} search path: {}\n", m_type_name, path); + con::debug("Adding {} search path: {}", m_type_name, path); searchPaths.CommitSearchPath(std::make_unique(path)); return true; } diff --git a/src/ObjCommon/InfoString/InfoString.cpp b/src/ObjCommon/InfoString/InfoString.cpp index 14efada8..c2c7a70e 100644 --- a/src/ObjCommon/InfoString/InfoString.cpp +++ b/src/ObjCommon/InfoString/InfoString.cpp @@ -1,5 +1,7 @@ #include "InfoString.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -172,13 +174,13 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream) std::string readPrefix; if (!infoStream.NextField(readPrefix)) { - std::cerr << "Invalid info string: Empty\n"; + con::error("Invalid info string: Empty"); return false; } if (prefix != readPrefix) { - std::cerr << "Invalid info string: Prefix \"" << readPrefix << "\" did not match expected prefix \"" << prefix << "\"\n"; + con::error("Invalid info string: Prefix \"{}\" did not match expected prefix \"{}\"", readPrefix, prefix); return false; } @@ -188,9 +190,9 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream) if (key.empty()) { if (m_keys_by_insertion.empty()) - std::cerr << "Invalid info string: Got empty key at the start of the info string\n"; + con::error("Invalid info string: Got empty key at the start of the info string"); else - std::cerr << "Invalid info string: Got empty key after key \"" << m_keys_by_insertion[m_keys_by_insertion.size() - 1] << "\"\n"; + con::error("Invalid info string: Got empty key after key \"{}\"", m_keys_by_insertion[m_keys_by_insertion.size() - 1]); return false; } @@ -198,7 +200,7 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream) std::string value; if (!infoStream.NextField(value)) { - std::cerr << "Invalid info string: Unexpected eof, no value for key \"" << key << "\"\n"; + con::error("Invalid info string: Unexpected eof, no value for key \"{}\"", key); return false; } diff --git a/src/ObjCommon/Obj/Gdt/GdtStream.cpp b/src/ObjCommon/Obj/Gdt/GdtStream.cpp index 1416a6de..fc3f6139 100644 --- a/src/ObjCommon/Obj/Gdt/GdtStream.cpp +++ b/src/ObjCommon/Obj/Gdt/GdtStream.cpp @@ -1,5 +1,7 @@ #include "GdtStream.h" +#include "Utils/Logging/Log.h" + #include #include @@ -14,7 +16,7 @@ public: void GdtReader::PrintError(const std::string& message) const { - std::cout << "GDT Error at line " << m_line << ": " << message << "\n"; + con::error("GDT Error at line {}: {}", m_line, message); } int GdtReader::PeekChar() diff --git a/src/ObjCommon/SearchPath/OutputPathFilesystem.cpp b/src/ObjCommon/SearchPath/OutputPathFilesystem.cpp index 038c5666..05945305 100644 --- a/src/ObjCommon/SearchPath/OutputPathFilesystem.cpp +++ b/src/ObjCommon/SearchPath/OutputPathFilesystem.cpp @@ -1,5 +1,7 @@ #include "OutputPathFilesystem.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -24,14 +26,14 @@ std::unique_ptr OutputPathFilesystem::Open(const std::string& file fs::create_directories(containingDirectory, ec); if (ec) { - std::cerr << std::format("Failed to create folder '{}' when try to open file '{}'\n", containingDirectory.string(), fileName); + con::error("Failed to create folder '{}' when try to open file '{}'", containingDirectory.string(), fileName); return nullptr; } std::ofstream stream(fullNewPath, std::ios::binary | std::ios::out); if (!stream.is_open()) { - std::cerr << std::format("Failed to open file '{}'\n", fileName); + con::error("Failed to open file '{}'", fileName); return nullptr; } diff --git a/src/ObjCommon/SearchPath/SearchPathFilesystem.cpp b/src/ObjCommon/SearchPath/SearchPathFilesystem.cpp index a87f972e..4cd54d62 100644 --- a/src/ObjCommon/SearchPath/SearchPathFilesystem.cpp +++ b/src/ObjCommon/SearchPath/SearchPathFilesystem.cpp @@ -1,5 +1,6 @@ #include "SearchPathFilesystem.h" +#include "Utils/Logging/Log.h" #include "Utils/ObjFileStream.h" #include @@ -59,6 +60,6 @@ void SearchPathFilesystem::Find(const SearchPathSearchOptions& options, const st } catch (std::filesystem::filesystem_error& e) { - std::cerr << std::format("Directory Iterator threw error when trying to find files: \"{}\"\n", e.what()); + con::error("Directory Iterator threw error when trying to find files: \"{}\"", e.what()); } } diff --git a/src/ObjCommon/Sound/FlacDecoder.cpp b/src/ObjCommon/Sound/FlacDecoder.cpp index 3ef8008c..a7c4fc0e 100644 --- a/src/ObjCommon/Sound/FlacDecoder.cpp +++ b/src/ObjCommon/Sound/FlacDecoder.cpp @@ -4,6 +4,7 @@ #include "Utils/ClassUtils.h" #include "Utils/Endianness.h" #include "Utils/FileUtils.h" +#include "Utils/Logging/Log.h" #include #include @@ -232,7 +233,7 @@ namespace flac } catch (const FlacReadingException& e) { - std::cerr << e.what() << "\n"; + con::error(e.what()); } return false; diff --git a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp index 82d6ceb5..76897870 100644 --- a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp @@ -16,6 +16,7 @@ #include "Techset/TechniqueStateMapCache.h" #include "Techset/TechsetCommon.h" #include "Techset/TechsetDefinitionCache.h" +#include "Utils/Logging/Log.h" #include #include @@ -248,7 +249,7 @@ namespace else throw GdtReadingException("ColorMap may not be blank in particle cloud materials"); - std::cout << std::format("Using particlecloud for \"{}\"\n", m_material.info.name); + con::info("Using particlecloud for \"{}\"", m_material.info.name); } void mtl_tools_template() @@ -1362,7 +1363,7 @@ namespace } catch (const GdtReadingException& e) { - std::cerr << std::format("Error while trying to load material from gdt: {} @ GdtEntry \"{}\"\n", e.what(), entry->m_name); + con::error("Error while trying to load material from gdt: {} @ GdtEntry \"{}\"", e.what(), entry->m_name); } return AssetCreationResult::Failure(); diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp index 50fe5b4e..7627004b 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp @@ -13,6 +13,7 @@ #include "Techset/TechsetDefinitionCache.h" #include "Techset/TechsetFileReader.h" #include "Utils/Alignment.h" +#include "Utils/Logging/Log.h" #include #include @@ -103,7 +104,7 @@ namespace if (shaderSize % sizeof(uint32_t) != 0) { - std::cerr << std::format("Invalid shader \"{}\": Size must be dividable by {}\n", fileName, sizeof(uint32_t)); + con::error("Invalid shader \"{}\": Size must be dividable by {}", fileName, sizeof(uint32_t)); return nullptr; } diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp index 9ce59278..5c4144b8 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp @@ -2,6 +2,7 @@ #include "Game/IW4/IW4.h" #include "Game/IW4/TechsetConstantsIW4.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,28 +32,28 @@ namespace { if (decl->streamCount >= std::extent_v) { - std::cerr << std::format("Failed to add vertex decl stream. Too many abbreviations: {}\n", assetName); + con::error("Failed to add vertex decl stream. Too many abbreviations: {}", assetName); return AssetCreationResult::Failure(); } std::string destinationAbbreviation; if (!NextAbbreviation(assetName, destinationAbbreviation, currentOffset)) { - std::cerr << std::format("Failed to detect vertex decl destination abbreviation: {}\n", assetName); + con::error("Failed to detect vertex decl destination abbreviation: {}", assetName); return AssetCreationResult::Failure(); } const auto foundSourceAbbreviation = std::ranges::find(materialStreamSourceAbbreviation, sourceAbbreviation); if (foundSourceAbbreviation == std::end(materialStreamSourceAbbreviation)) { - std::cerr << std::format("Unknown vertex decl source abbreviation: {}\n", sourceAbbreviation); + con::error("Unknown vertex decl source abbreviation: {}", sourceAbbreviation); return AssetCreationResult::Failure(); } const auto foundDestinationAbbreviation = std::ranges::find(materialStreamDestinationAbbreviation, destinationAbbreviation); if (foundDestinationAbbreviation == std::end(materialStreamDestinationAbbreviation)) { - std::cerr << std::format("Unknown vertex decl destination abbreviation: {}\n", destinationAbbreviation); + con::error("Unknown vertex decl destination abbreviation: {}", destinationAbbreviation); return AssetCreationResult::Failure(); } diff --git a/src/ObjCompiling/Image/IPak/IPakCreator.cpp b/src/ObjCompiling/Image/IPak/IPakCreator.cpp index 1f3fd36a..370074d2 100644 --- a/src/ObjCompiling/Image/IPak/IPakCreator.cpp +++ b/src/ObjCompiling/Image/IPak/IPakCreator.cpp @@ -4,6 +4,7 @@ #include "GitVersion.h" #include "ObjContainer/IPak/IPakTypes.h" #include "Utils/Alignment.h" +#include "Utils/Logging/Log.h" #include #include @@ -143,7 +144,7 @@ namespace const auto openFile = m_search_path.Open(fileName); if (!openFile.IsOpen()) { - std::cerr << std::format("Failed to open file for ipak: {}\n", fileName); + con::error("Failed to open file for ipak: {}", fileName); return nullptr; } @@ -388,14 +389,14 @@ namespace image const auto file = outPath.Open(std::format("{}.ipak", m_name)); if (!file) { - std::cerr << std::format("Failed to open file for ipak {}\n", m_name); + con::error("Failed to open file for ipak {}", m_name); return; } IPakWriter writer(*file, searchPath, m_image_names); writer.Write(); - std::cout << std::format("Created ipak {} with {} entries\n", m_name, m_image_names.size()); + con::info("Created ipak {} with {} entries", m_name, m_image_names.size()); } const std::vector& IPakToCreate::GetImageNames() const diff --git a/src/ObjCompiling/Iwd/IwdCreator.cpp b/src/ObjCompiling/Iwd/IwdCreator.cpp index 3715f480..aa79fce1 100644 --- a/src/ObjCompiling/Iwd/IwdCreator.cpp +++ b/src/ObjCompiling/Iwd/IwdCreator.cpp @@ -1,6 +1,7 @@ #include "IwdCreator.h" #include "Utils/FileToZlibWrapper.h" +#include "Utils/Logging/Log.h" #include #include @@ -24,7 +25,7 @@ void IwdToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath) const auto file = outPath.Open(fileName); if (!file) { - std::cerr << std::format("Failed to open file for iwd {}\n", m_name); + con::error("Failed to open file for iwd {}", m_name); return; } @@ -33,7 +34,7 @@ void IwdToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath) const auto zipFile = zipOpen2(fileName.c_str(), APPEND_STATUS_CREATE, nullptr, &functions); if (!zipFile) { - std::cerr << std::format("Failed to open file as zip for iwd {}\n", m_name); + con::error("Failed to open file as zip for iwd {}", m_name); return; } @@ -42,7 +43,7 @@ void IwdToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath) auto readFile = searchPath.Open(filePath); if (!readFile.IsOpen()) { - std::cerr << std::format("Failed to open file for iwd: {}\n", filePath); + con::error("Failed to open file for iwd: {}", filePath); continue; } @@ -76,7 +77,7 @@ void IwdToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath) zipClose(zipFile, nullptr); - std::cout << std::format("Created iwd {} with {} entries\n", m_name, m_file_paths.size()); + con::info("Created iwd {} with {} entries", m_name, m_file_paths.size()); } const std::vector& IwdToCreate::GetFilePaths() const @@ -100,7 +101,7 @@ IwdToCreate* IwdCreator::GetOrAddIwd(const std::string& iwdName) void IwdCreator::Finalize(ISearchPath& searchPath, IOutputPath& outPath) { - std::cout << std::format("Writing {} iwd files to disk\n", m_iwds.size()); + con::info("Writing {} iwd files to disk", m_iwds.size()); for (const auto& iwdToCreate : m_iwds) iwdToCreate->Build(searchPath, outPath); diff --git a/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp b/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp index ec9b2cc8..26136f12 100644 --- a/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp +++ b/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp @@ -1,5 +1,7 @@ #include "KeyValuePairsCreator.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -41,7 +43,7 @@ namespace key_value_pairs if (endPtr != &strValue[strValue.size()]) { - std::cerr << std::format("Could not parse metadata key \"{}\" as hash\n", metaData.first); + con::error("Could not parse metadata key \"{}\" as hash", metaData.first); continue; } diff --git a/src/ObjImage/Image/DdsLoader.cpp b/src/ObjImage/Image/DdsLoader.cpp index 6fbd617b..5bd4e4b4 100644 --- a/src/ObjImage/Image/DdsLoader.cpp +++ b/src/ObjImage/Image/DdsLoader.cpp @@ -3,6 +3,7 @@ #include "Image/DdsTypes.h" #include "Utils/ClassUtils.h" #include "Utils/FileUtils.h" +#include "Utils/Logging/Log.h" #include #include @@ -41,13 +42,13 @@ namespace dds m_stream.read(reinterpret_cast(&magic), sizeof(magic)); if (m_stream.gcount() != sizeof(magic)) { - std::cerr << "Failed to read dds data\n"; + con::error("Failed to read dds data"); return false; } if (magic != DDS_MAGIC) { - std::cerr << "Invalid magic for dds\n"; + con::error("Invalid magic for dds"); return false; } @@ -60,7 +61,7 @@ namespace dds m_stream.read(reinterpret_cast(&headerDx10), sizeof(headerDx10)); if (m_stream.gcount() != sizeof(headerDx10)) { - std::cerr << "Failed to read dds data\n"; + con::error("Failed to read dds data"); return false; } @@ -81,7 +82,7 @@ namespace dds } else { - std::cerr << std::format("Unsupported dds resourceDimension {}\n", static_cast(headerDx10.resourceDimension)); + con::error("Unsupported dds resourceDimension {}", static_cast(headerDx10.resourceDimension)); return false; } @@ -94,7 +95,7 @@ namespace dds } } - std::cerr << std::format("Unsupported dds dxgi format {}\n", static_cast(headerDx10.dxgiFormat)); + con::error("Unsupported dds dxgi format {}", static_cast(headerDx10.dxgiFormat)); return false; } @@ -118,7 +119,7 @@ namespace dds return ReadDxt10Header(); default: - std::cerr << std::format("Unknown dds FourCC {}\n", pf.dwFourCC); + con::error("Unknown dds FourCC {}", pf.dwFourCC); return false; } } @@ -169,8 +170,7 @@ namespace dds } } - std::cerr << std::format( - "Failed to find dds pixel format: R={:#x} G={:#x} B={:#x} A={:#x}\n", pf.dwRBitMask, pf.dwGBitMask, pf.dwBBitMask, pf.dwABitMask); + con::error("Failed to find dds pixel format: R={:#x} G={:#x} B={:#x} A={:#x}", pf.dwRBitMask, pf.dwGBitMask, pf.dwBBitMask, pf.dwABitMask); return false; } @@ -189,7 +189,7 @@ namespace dds m_stream.read(reinterpret_cast(&header), sizeof(header)); if (m_stream.gcount() != sizeof(header)) { - std::cerr << "Failed to read dds data\n"; + con::error("Failed to read dds data"); return false; } @@ -249,7 +249,7 @@ namespace dds if (m_stream.gcount() != mipSize) { - std::cerr << "Failed to read texture data from dds\n"; + con::error("Failed to read texture data from dds"); return nullptr; } } diff --git a/src/ObjImage/Image/IwiLoader.cpp b/src/ObjImage/Image/IwiLoader.cpp index 8d6bc028..4f0e5df5 100644 --- a/src/ObjImage/Image/IwiLoader.cpp +++ b/src/ObjImage/Image/IwiLoader.cpp @@ -1,6 +1,7 @@ #include "IwiLoader.h" #include "Image/IwiTypes.h" +#include "Utils/Logging/Log.h" #include #include @@ -36,10 +37,10 @@ namespace iwi case iwi6::IwiFormat::IMG_FORMAT_WAVELET_LUMINANCE_ALPHA: case iwi6::IwiFormat::IMG_FORMAT_WAVELET_LUMINANCE: case iwi6::IwiFormat::IMG_FORMAT_WAVELET_ALPHA: - std::cerr << std::format("Unsupported IWI format: {}\n", format); + con::error("Unsupported IWI format: {}", format); break; default: - std::cerr << std::format("Unknown IWI format: {}\n", format); + con::error("Unknown IWI format: {}", format); break; } @@ -84,14 +85,14 @@ namespace iwi if (currentMipLevel < static_cast(std::extent_v) && currentFileSize != header.fileSizeForPicmip[currentMipLevel]) { - std::cerr << std::format("Iwi has invalid file size for picmip {}\n", currentMipLevel); + con::error("Iwi has invalid file size for picmip {}", currentMipLevel); return nullptr; } stream.read(reinterpret_cast(texture->GetBufferForMipLevel(currentMipLevel)), sizeOfMipLevel); if (stream.gcount() != sizeOfMipLevel) { - std::cerr << std::format("Unexpected eof of iwi in mip level {}\n", currentMipLevel); + con::error("Unexpected eof of iwi in mip level {}", currentMipLevel); return nullptr; } } @@ -134,10 +135,10 @@ namespace iwi case iwi8::IwiFormat::IMG_FORMAT_DXN_AS_LUMINANCE_ALPHA: case iwi8::IwiFormat::IMG_FORMAT_DXT1_AS_LUMINANCE: case iwi8::IwiFormat::IMG_FORMAT_DXT1_AS_ALPHA: - std::cerr << std::format("Unsupported IWI format: {}\n", format); + con::error("Unsupported IWI format: {}", format); break; default: - std::cerr << std::format("Unknown IWI format: {}\n", format); + con::error("Unknown IWI format: {}", format); break; } @@ -176,12 +177,12 @@ namespace iwi } else if ((header.flags & iwi8::IwiFlags::IMG_FLAG_MAPTYPE_MASK) == iwi8::IwiFlags::IMG_FLAG_MAPTYPE_1D) { - std::cerr << "Iwi has unsupported map type 1D\n"; + con::error("Iwi has unsupported map type 1D"); return nullptr; } else { - std::cerr << "Iwi has unsupported map type\n"; + con::error("Iwi has unsupported map type"); return nullptr; } @@ -198,14 +199,14 @@ namespace iwi if (currentMipLevel < static_cast(std::extent_v) && currentFileSize != header.fileSizeForPicmip[currentMipLevel]) { - std::cerr << std::format("Iwi has invalid file size for picmip {}\n", currentMipLevel); + con::error("Iwi has invalid file size for picmip {}", currentMipLevel); return nullptr; } stream.read(reinterpret_cast(texture->GetBufferForMipLevel(currentMipLevel)), sizeOfMipLevel); if (stream.gcount() != sizeOfMipLevel) { - std::cerr << std::format("Unexpected eof of iwi in mip level {}\n", currentMipLevel); + con::error("Unexpected eof of iwi in mip level {}", currentMipLevel); return nullptr; } } @@ -245,10 +246,10 @@ namespace iwi case iwi13::IwiFormat::IMG_FORMAT_BITMAP_C8: case iwi13::IwiFormat::IMG_FORMAT_BITMAP_RGBA8: case iwi13::IwiFormat::IMG_FORMAT_A16B16G16R16F: - std::cerr << std::format("Unsupported IWI format: {}\n", format); + con::error("Unsupported IWI format: {}", format); break; default: - std::cerr << std::format("Unknown IWI format: {}\n", format); + con::error("Unknown IWI format: {}", format); break; } @@ -293,14 +294,14 @@ namespace iwi if (currentMipLevel < static_cast(std::extent_v) && currentFileSize != header.fileSizeForPicmip[currentMipLevel]) { - std::cerr << std::format("Iwi has invalid file size for picmip {}\n", currentMipLevel); + con::error("Iwi has invalid file size for picmip {}", currentMipLevel); return nullptr; } stream.read(reinterpret_cast(texture->GetBufferForMipLevel(currentMipLevel)), sizeOfMipLevel); if (stream.gcount() != sizeOfMipLevel) { - std::cerr << std::format("Unexpected eof of iwi in mip level {}\n", currentMipLevel); + con::error("Unexpected eof of iwi in mip level {}", currentMipLevel); return nullptr; } } @@ -342,10 +343,10 @@ namespace iwi case iwi27::IwiFormat::IMG_FORMAT_BITMAP_RGB5A3: case iwi27::IwiFormat::IMG_FORMAT_BITMAP_C8: case iwi27::IwiFormat::IMG_FORMAT_BITMAP_RGBA8: - std::cerr << std::format("Unsupported IWI format: {}\n", format); + con::error("Unsupported IWI format: {}", format); break; default: - std::cerr << std::format("Unknown IWI format: {}\n", format); + con::error("Unknown IWI format: {}", format); break; } @@ -390,14 +391,14 @@ namespace iwi if (currentMipLevel < static_cast(std::extent_v) && currentFileSize != header.fileSizeForPicmip[currentMipLevel]) { - std::cerr << std::format("Iwi has invalid file size for picmip {}\n", currentMipLevel); + con::error("Iwi has invalid file size for picmip {}", currentMipLevel); return nullptr; } stream.read(reinterpret_cast(texture->GetBufferForMipLevel(currentMipLevel)), sizeOfMipLevel); if (stream.gcount() != sizeOfMipLevel) { - std::cerr << std::format("Unexpected eof of iwi in mip level {}\n", currentMipLevel); + con::error("Unexpected eof of iwi in mip level {}", currentMipLevel); return nullptr; } } @@ -415,7 +416,7 @@ namespace iwi if (iwiVersion.tag[0] != 'I' || iwiVersion.tag[1] != 'W' || iwiVersion.tag[2] != 'i') { - std::cerr << "Invalid IWI magic\n"; + con::error("Invalid IWI magic"); return nullptr; } @@ -437,7 +438,7 @@ namespace iwi break; } - std::cerr << std::format("Unknown IWI version {}\n", iwiVersion.version); + con::error("Unknown IWI version {}", iwiVersion.version); return nullptr; } } // namespace iwi diff --git a/src/ObjLoading/Asset/AssetCreationContext.cpp b/src/ObjLoading/Asset/AssetCreationContext.cpp index a7de8976..7624716c 100644 --- a/src/ObjLoading/Asset/AssetCreationContext.cpp +++ b/src/ObjLoading/Asset/AssetCreationContext.cpp @@ -1,5 +1,7 @@ #include "AssetCreationContext.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -87,7 +89,7 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo)); if (addedAsset == nullptr) - std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName); + con::error("Failed to add asset of type \"{}\" to pool: \"{}\"", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName); return addedAsset; } @@ -97,7 +99,7 @@ XAssetInfoGeneric* AssetCreationContext::LoadDefaultAssetDependency(const asset_ if (result.HasTakenAction() && !result.HasFailed()) return result.GetAssetInfo(); - std::cerr << std::format("Failed to create default asset of type {}\n", *m_zone.m_pools->GetAssetTypeName(assetType)); + con::error("Failed to create default asset of type {}", *m_zone.m_pools->GetAssetTypeName(assetType)); return nullptr; } @@ -127,11 +129,11 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_ if (!result.HasFailed()) return result.GetAssetInfo(); - std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + con::error("Could not load asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); } else { - std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + con::error("Missing asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); } return nullptr; @@ -149,7 +151,7 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(c const auto result = m_creators->CreateAsset(assetType, assetName, *this); if (!result.HasTakenAction() && !result.HasFailed()) { - std::cerr << std::format("Could not load indirectly referenced asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + con::warn("Could not load indirectly referenced asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); } return IndirectAssetReference(assetType, assetName); } @@ -185,11 +187,11 @@ XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_ if (!result.HasFailed()) return result.GetAssetInfo(); - std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + con::error("Could not load asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); } else { - std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); + con::error("Missing asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType)); } return nullptr; diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp index b7f03a20..8e876432 100644 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp +++ b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp @@ -4,6 +4,7 @@ #include "Image/DdsLoader.h" #include "Image/IwiTypes.h" #include "Pool/GlobalAssetPool.h" +#include "Utils/Logging/Log.h" #include #include @@ -40,7 +41,7 @@ namespace const auto texture = dds::LoadDds(*file.m_stream); if (!texture) { - std::cerr << std::format("Failed to load dds file for image asset \"{}\"\n", assetName); + con::error("Failed to load dds file for image asset \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp index 5172498a..5d911fa6 100644 --- a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp +++ b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp @@ -3,6 +3,7 @@ #include "Game/IW3/IW3.h" #include "Game/IW3/Material/JsonMaterialLoaderIW3.h" #include "Material/MaterialCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -32,7 +33,7 @@ namespace AssetRegistration registration(assetName, material); if (!LoadMaterialAsJson(*file.m_stream, *material, m_memory, context, registration)) { - std::cerr << std::format("Failed to load material \"{}\"\n", assetName); + con::error("Failed to load material \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp index 112076a7..e9703fc2 100644 --- a/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp +++ b/src/ObjLoading/Game/IW4/InfoString/InfoStringToStructConverter.cpp @@ -1,5 +1,7 @@ #include "InfoStringToStructConverter.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -63,7 +65,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (fx == nullptr) { - std::cerr << std::format("Failed to load fx asset \"{}\"\n", value); + con::error("Failed to load fx asset \"{}\"", value); return false; } @@ -85,7 +87,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (xmodel == nullptr) { - std::cerr << std::format("Failed to load xmodel asset \"{}\"\n", value); + con::error("Failed to load xmodel asset \"{}\"", value); return false; } @@ -107,7 +109,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (material == nullptr) { - std::cerr << std::format("Failed to load material asset \"{}\"\n", value); + con::error("Failed to load material asset \"{}\"", value); return false; } @@ -129,7 +131,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (tracer == nullptr) { - std::cerr << std::format("Failed to load tracer asset \"{}\"\n", value); + con::error("Failed to load tracer asset \"{}\"", value); return false; } @@ -146,7 +148,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as mph\n", value); + con::error("Failed to parse value \"{}\" as mph", value); return false; } @@ -165,7 +167,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (collmap == nullptr) { - std::cerr << std::format("Failed to load collmap asset \"{}\"\n", value); + con::error("Failed to load collmap asset \"{}\"", value); return false; } diff --git a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp index b0acadf4..9065aa75 100644 --- a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp +++ b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp @@ -3,6 +3,7 @@ #include "Game/IW4/IW4.h" #include "Game/IW4/Leaderboard/JsonLeaderboardDef.h" #include "Leaderboard/LeaderboardCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -36,7 +37,7 @@ namespace if (type != "leaderboard" || version != 1u) { - std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); + con::error("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1", leaderboardDef.name); return false; } @@ -45,7 +46,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); + con::error("Failed to parse json of leaderboard: {}", e.what()); } return false; @@ -125,7 +126,7 @@ namespace const JsonLoader loader(*file.m_stream, m_memory); if (!loader.Load(*leaderboardDef)) { - std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); + con::error("Failed to load leaderboard \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp index 1485c361..f4722b58 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp @@ -2,6 +2,7 @@ #include "Game/IW4/IW4.h" #include "LightDef/LightDefCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -49,7 +50,7 @@ namespace auto* imageDependency = context.LoadDependency(imageName); if (!imageDependency) { - std::cerr << std::format("Could not load GfxLightDef \"{}\" due to missing image \"{}\"\n", assetName, imageName); + con::error("Could not load GfxLightDef \"{}\" due to missing image \"{}\"", assetName, imageName); return AssetCreationResult::Failure(); } registration.AddDependency(imageDependency); diff --git a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp index b6367630..9f921012 100644 --- a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp +++ b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp @@ -3,6 +3,7 @@ #include "Game/IW4/IW4.h" #include "Game/IW4/Material/JsonMaterialLoaderIW4.h" #include "Material/MaterialCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -32,7 +33,7 @@ namespace AssetRegistration registration(assetName, material); if (!LoadMaterialAsJson(*file.m_stream, *material, m_memory, context, registration)) { - std::cerr << std::format("Failed to load material \"{}\"\n", assetName); + con::error("Failed to load material \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp index 91fb70a0..98ede01a 100644 --- a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp +++ b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp @@ -5,6 +5,7 @@ #include "Game/IW4/Menu/MenuConverterIW4.h" #include "ObjLoading.h" #include "Parsing/Menu/MenuFileReader.h" +#include "Utils/Logging/Log.h" #include #include @@ -88,7 +89,7 @@ namespace const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath); if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end()) { - std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath); + con::debug("Already loaded \"{}\", skipping", menuFilePath); for (auto* menu : alreadyLoadedMenuFile->second) { menus.emplace_back(menu->Asset()); @@ -100,7 +101,7 @@ namespace const auto file = m_search_path.Open(menuFilePath); if (!file.IsOpen()) { - std::cerr << std::format("Could not open menu file \"{}\"\n", menuFilePath); + con::error("Could not open menu file \"{}\"", menuFilePath); return false; } @@ -109,12 +110,12 @@ namespace { ProcessParsedResults(menuFilePath, context, *menuFileResult, zoneState, conversionState, menus, registration); if (!menuFileResult->m_menus_to_load.empty()) - std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath); + con::warn("Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"", menuFilePath); return true; } else - std::cerr << std::format("Could not read menu file \"{}\"\n", menuFilePath); + con::error("Could not read menu file \"{}\"", menuFilePath); return false; } @@ -134,12 +135,12 @@ namespace for (const auto& menu : parsingResult.m_menus) totalItemCount += menu->m_items.size(); - std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n", - fileName, - menuLoadCount, - menuCount, - functionCount, - totalItemCount); + con::info("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)", + fileName, + menuLoadCount, + menuCount, + functionCount, + totalItemCount); // Add all functions to the zone state to make them available for all menus to be converted for (auto& function : parsingResult.m_functions) @@ -160,7 +161,7 @@ namespace converter->ConvertMenu(*commonMenu, *menuAsset, menuRegistration); if (menuAsset == nullptr) { - std::cerr << std::format("Failed to convert menu file \"{}\"\n", commonMenu->m_name); + con::error("Failed to convert menu file \"{}\"", commonMenu->m_name); return false; } diff --git a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp index 26634fd7..cc5a0525 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp @@ -4,6 +4,7 @@ #include "Game/IW4/ObjConstantsIW4.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysPresetIW4.h" +#include "Utils/Logging/Log.h" #include #include @@ -30,7 +31,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read phys preset gdt entry: \"{}\"\n", assetName); + con::error("Failed to read phys preset gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp index e8b69203..813ff137 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp @@ -3,6 +3,7 @@ #include "Game/IW4/IW4.h" #include "Game/IW4/InfoString/InfoStringToStructConverter.h" #include "Game/IW4/PhysPreset/PhysPresetFields.h" +#include "Utils/Logging/Log.h" #include #include @@ -78,7 +79,7 @@ namespace phys_preset infoString, &presetInfo, m_zone.m_script_strings, m_memory, context, registration, phys_preset_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName); + con::error("Failed to parse phys preset: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp index 5d05a588..b9745054 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp @@ -5,6 +5,7 @@ #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysPresetIW4.h" #include "PhysPreset/PhysPresetCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -32,7 +33,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp index 2b25158a..58c09255 100644 --- a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp +++ b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp @@ -1,6 +1,7 @@ #include "LoaderRawFileIW4.h" #include "Game/IW4/IW4.h" +#include "Utils/Logging/Log.h" #include #include @@ -58,7 +59,7 @@ namespace if (ret != Z_STREAM_END) { - std::cerr << std::format("Deflate failed for loading rawfile \"{}\"\n", assetName); + con::error("Deflate failed for loading rawfile \"{}\"", assetName); deflateEnd(&zs); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp index 1d6ad597..4450dc92 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp @@ -2,6 +2,7 @@ #include "Game/IW4/IW4.h" #include "Shader/ShaderCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -29,7 +30,7 @@ namespace if (file.m_length % sizeof(uint32_t) != 0) { - std::cerr << std::format("Invalid pixel shader \"{}\": Size must be dividable by {}\n", assetName, sizeof(uint32_t)); + con::error("Invalid pixel shader \"{}\": Size must be dividable by {}", assetName, sizeof(uint32_t)); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp index 99bea4dd..79fcff64 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp @@ -2,6 +2,7 @@ #include "Game/IW4/IW4.h" #include "Shader/ShaderCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -29,7 +30,7 @@ namespace if (file.m_length % sizeof(uint32_t) != 0) { - std::cerr << std::format("Invalid vertex shader \"{}\": Size must be dividable by {}\n", assetName, sizeof(uint32_t)); + con::error("Invalid vertex shader \"{}\": Size must be dividable by {}", assetName, sizeof(uint32_t)); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp index 765b4bfb..e6aeeab4 100644 --- a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp +++ b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp @@ -5,6 +5,7 @@ #include "Parsing/Graph2D/Graph2DReader.h" #include "Pool/GlobalAssetPool.h" #include "Sound/SoundCurveCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -38,7 +39,7 @@ namespace if (sndCurveData->knots.size() > std::extent_v) { - std::cerr << std::format("Failed to load SndCurve \"{}\": Too many knots ({})\n", assetName, sndCurveData->knots.size()); + con::error("Failed to load SndCurve \"{}\": Too many knots ({})", assetName, sndCurveData->knots.size()); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp index ef632e47..b8fbf7bf 100644 --- a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp @@ -4,6 +4,7 @@ #include "Game/IW4/ObjConstantsIW4.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderWeaponIW4.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read weapon gdt entry: \"{}\"\n", assetName); + con::error("Failed to read weapon gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp index be8ac8d6..6bfe7f07 100644 --- a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp @@ -4,6 +4,7 @@ #include "Game/IW4/InfoString/EnumStrings.h" #include "Game/IW4/InfoString/InfoStringToStructConverter.h" #include "Game/IW4/Weapon/WeaponFields.h" +#include "Utils/Logging/Log.h" #include "Weapon/AccuracyGraphLoader.h" #include @@ -23,13 +24,13 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse hide tags as array\n"; + con::error("Failed to parse hide tags as array"); return false; } if (valueArray.size() > std::extent_v) { - std::cerr << std::format("Cannot have more than {} hide tags!\n", std::extent_v); + con::error("Cannot have more than {} hide tags!", std::extent_v); return false; } @@ -85,14 +86,13 @@ namespace std::vector> pairs; if (!ParseAsArray(value, pairs)) { - std::cerr << std::format("Failed to parse notetrack{}map as pairs\n", mapName); + con::error("Failed to parse notetrack{}map as pairs", mapName); return false; } if (pairs.size() > std::extent_v) { - std::cerr << std::format( - "Cannot have more than {} notetrack{}map entries!\n", std::extent_v, mapName); + con::error("Cannot have more than {} notetrack{}map entries!", std::extent_v, mapName); return false; } @@ -267,28 +267,27 @@ namespace void CheckProjectileValues(const WeaponCompleteDef& weaponCompleteDef, const WeaponDef& weaponDef) { if (weaponDef.iProjectileSpeed <= 0) - std::cerr << std::format("Projectile speed for WeapType {} must be greater than 0.0", weaponCompleteDef.szDisplayName); + con::error("Projectile speed for WeapType {} must be greater than 0.0", weaponCompleteDef.szDisplayName); if (weaponDef.destabilizationCurvatureMax >= 1000000000.0f || weaponDef.destabilizationCurvatureMax < 0.0f) - std::cerr << std::format("Destabilization angle for for WeapType {} must be between 0 and 45 degrees", weaponCompleteDef.szDisplayName); + con::error("Destabilization angle for for WeapType {} must be between 0 and 45 degrees", weaponCompleteDef.szDisplayName); if (weaponDef.destabilizationRateTime < 0.0f) - std::cerr << std::format("Destabilization rate time for for WeapType {} must be non-negative", weaponCompleteDef.szDisplayName); + con::error("Destabilization rate time for for WeapType {} must be non-negative", weaponCompleteDef.szDisplayName); } void CheckTurretBarrelSpin(const WeaponCompleteDef& weaponCompleteDef, const WeaponDef& weaponDef) { if (weaponDef.weapClass != WEAPCLASS_TURRET) - std::cerr << std::format("Rotating barrel set for non-turret weapon {}.", weaponCompleteDef.szInternalName); + con::error("Rotating barrel set for non-turret weapon {}.", weaponCompleteDef.szInternalName); if (0.0f == weaponDef.turretBarrelSpinSpeed) { - std::cerr << std::format( - "Rotating barrel spin speed '{}' is invalid for weapon {}.", weaponDef.turretBarrelSpinSpeed, weaponCompleteDef.szInternalName); + con::error("Rotating barrel spin speed '{}' is invalid for weapon {}.", weaponDef.turretBarrelSpinSpeed, weaponCompleteDef.szInternalName); } if (0.0f < weaponDef.turretOverheatUpRate && 0.0f >= weaponDef.turretOverheatDownRate) { - std::cerr << std::format("Turret overheat Up rate is set, but the down rate '{}' is invalid for weapon {}.", - weaponDef.turretOverheatDownRate, - weaponCompleteDef.szInternalName); + con::error("Turret overheat Up rate is set, but the down rate '{}' is invalid for weapon {}.", + weaponDef.turretOverheatDownRate, + weaponCompleteDef.szInternalName); } } @@ -296,18 +295,18 @@ namespace { if (0.0f != weaponDef.fAdsZoomInFrac) { - std::cerr << std::format("Weapon {} ({}) has thermal scope set. ADS Zoom In frac should be 0 to prevent zoom-in blur ({}).\n", - weaponCompleteDef.szInternalName, - weaponCompleteDef.szDisplayName, - weaponDef.fAdsZoomInFrac); + con::error("Weapon {} ({}) has thermal scope set. ADS Zoom In frac should be 0 to prevent zoom-in blur ({}).", + weaponCompleteDef.szInternalName, + weaponCompleteDef.szDisplayName, + weaponDef.fAdsZoomInFrac); } if (0.0f != weaponDef.fAdsZoomOutFrac) { - std::cerr << std::format("Weapon {} ({}) has thermal scope set. ADS Zoom Out frac should be 0 to prevent zoom-out blur ({}).\n", - weaponCompleteDef.szInternalName, - weaponCompleteDef.szDisplayName, - weaponDef.fAdsZoomOutFrac); + con::error("Weapon {} ({}) has thermal scope set. ADS Zoom Out frac should be 0 to prevent zoom-out blur ({}).", + weaponCompleteDef.szInternalName, + weaponCompleteDef.szDisplayName, + weaponDef.fAdsZoomOutFrac); } } @@ -337,7 +336,7 @@ namespace weaponDef.fMinDamageRange = 999999.12f; if (weaponDef.enemyCrosshairRange > 15000.0f) - std::cerr << std::format("Enemy crosshair ranges should be less than {}\n", 15000.0f); + con::error("Enemy crosshair ranges should be less than {}", 15000.0f); if (weaponDef.weapType == WEAPTYPE_PROJECTILE) CheckProjectileValues(weaponCompleteDef, weaponDef); @@ -350,22 +349,21 @@ namespace if (weaponDef.offhandClass && !weaponDef.bClipOnly) { - std::cerr << std::format( - "Weapon {} ({}) is an offhand weapon but is not set to clip only, which is not supported since we can't reload the offhand slot.\n", - weaponCompleteDef.szInternalName, - weaponCompleteDef.szDisplayName); + con::error("Weapon {} ({}) is an offhand weapon but is not set to clip only, which is not supported since we can't reload the offhand slot.", + weaponCompleteDef.szInternalName, + weaponCompleteDef.szDisplayName); } if (weaponDef.weapType == WEAPTYPE_BULLET) { if (weaponDef.bulletExplDmgMult <= 0.0f) - std::cerr << std::format("Detected invalid bulletExplDmgMult of '{}' for weapon '{}'; please update weapon settings.\n", - weaponDef.bulletExplDmgMult, - weaponCompleteDef.szInternalName); + con::error("Detected invalid bulletExplDmgMult of '{}' for weapon '{}'; please update weapon settings.", + weaponDef.bulletExplDmgMult, + weaponCompleteDef.szInternalName); if (weaponDef.bulletExplRadiusMult <= 0.0f) - std::cerr << std::format("Detected invalid bulletExplRadiusMult of '{}' for weapon '{}'; please update weapon settings.\n", - weaponDef.bulletExplRadiusMult, - weaponCompleteDef.szInternalName); + con::error("Detected invalid bulletExplRadiusMult of '{}' for weapon '{}'; please update weapon settings.", + weaponDef.bulletExplRadiusMult, + weaponCompleteDef.szInternalName); } } @@ -448,7 +446,7 @@ namespace weapon infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); + con::error("Failed to parse weapon: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp index ae6de026..a2382743 100644 --- a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp @@ -4,6 +4,7 @@ #include "Game/IW4/ObjConstantsIW4.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderWeaponIW4.h" +#include "Utils/Logging/Log.h" #include "Weapon/WeaponCommon.h" #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp index 0f812f80..a7f68cf4 100644 --- a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp +++ b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp @@ -3,6 +3,7 @@ #include "Game/IW5/IW5.h" #include "Image/ImageCommon.h" #include "Image/IwiLoader.h" +#include "Utils/Logging/Log.h" #include #include @@ -39,7 +40,7 @@ namespace const auto texture = iwi::LoadIwi(ss); if (!texture) { - std::cerr << std::format("Failed to load texture from: {}\n", fileName); + con::error("Failed to load texture from: {}", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp index 63be576b..0a07a98e 100644 --- a/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp +++ b/src/ObjLoading/Game/IW5/InfoString/InfoStringToStructConverter.cpp @@ -1,5 +1,7 @@ #include "InfoStringToStructConverter.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -63,7 +65,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (fx == nullptr) { - std::cerr << std::format("Failed to load fx asset \"{}\"\n", value); + con::error("Failed to load fx asset \"{}\"", value); return false; } @@ -85,7 +87,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (xmodel == nullptr) { - std::cerr << std::format("Failed to load xmodel asset \"{}\"\n", value); + con::error("Failed to load xmodel asset \"{}\"", value); return false; } @@ -107,7 +109,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (material == nullptr) { - std::cerr << std::format("Failed to load material asset \"{}\"\n", value); + con::error("Failed to load material asset \"{}\"", value); return false; } @@ -129,7 +131,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (tracer == nullptr) { - std::cerr << std::format("Failed to load tracer asset \"{}\"\n", value); + con::error("Failed to load tracer asset \"{}\"", value); return false; } @@ -146,7 +148,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (endPtr != &value[value.size()]) { - std::cout << "Failed to parse value \"" << value << "\" as mph\n"; + con::error("Failed to parse value \"{}\" as mph", value); return false; } @@ -165,7 +167,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (collmap == nullptr) { - std::cerr << std::format("Failed to load collmap asset \"{}\"\n", value); + con::error("Failed to load collmap asset \"{}\"", value); return false; } diff --git a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp index aa25767a..293740be 100644 --- a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp +++ b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp @@ -3,6 +3,7 @@ #include "Game/IW5/IW5.h" #include "Game/IW5/Leaderboard/JsonLeaderboardDef.h" #include "Leaderboard/LeaderboardCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -36,7 +37,7 @@ namespace if (type != "leaderboard" || version != 1u) { - std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); + con::error("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1", leaderboardDef.name); return false; } @@ -45,7 +46,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); + con::error("Failed to parse json of leaderboard: {}", e.what()); } return false; @@ -142,7 +143,7 @@ namespace const JsonLoader loader(*file.m_stream, m_memory); if (!loader.Load(*leaderboardDef)) { - std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); + con::error("Failed to load leaderboard \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp index 3a72f0bb..d41f0af2 100644 --- a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp +++ b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp @@ -3,6 +3,7 @@ #include "Game/IW5/IW5.h" #include "Game/IW5/Material/JsonMaterialLoaderIW5.h" #include "Material/MaterialCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -32,7 +33,7 @@ namespace AssetRegistration registration(assetName, material); if (!LoadMaterialAsJson(*file.m_stream, *material, m_memory, context, registration)) { - std::cerr << std::format("Failed to load material \"{}\"\n", assetName); + con::error("Failed to load material \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp index ca7414df..b16d7fcf 100644 --- a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp +++ b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp @@ -5,6 +5,7 @@ #include "Game/IW5/Menu/MenuConverterIW5.h" #include "ObjLoading.h" #include "Parsing/Menu/MenuFileReader.h" +#include "Utils/Logging/Log.h" #include #include @@ -88,7 +89,7 @@ namespace const auto alreadyLoadedMenuFile = conversionState.m_menus_by_filename.find(menuFilePath); if (alreadyLoadedMenuFile != conversionState.m_menus_by_filename.end()) { - std::cout << std::format("Already loaded \"{}\", skipping\n", menuFilePath); + con::debug("Already loaded \"{}\", skipping", menuFilePath); for (auto* menu : alreadyLoadedMenuFile->second) { menus.emplace_back(menu->Asset()); @@ -100,7 +101,7 @@ namespace const auto file = m_search_path.Open(menuFilePath); if (!file.IsOpen()) { - std::cerr << std::format("Could not open menu file \"{}\"\n", menuFilePath); + con::error("Could not open menu file \"{}\"", menuFilePath); return false; } @@ -109,12 +110,12 @@ namespace { ProcessParsedResults(menuFilePath, context, *menuFileResult, zoneState, conversionState, menus, registration); if (!menuFileResult->m_menus_to_load.empty()) - std::cout << std::format("WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"\n", menuFilePath); + con::warn("Menu file has menus to load even though it is not a menu list, ignoring: \"{}\"", menuFilePath); return true; } else - std::cerr << std::format("Could not read menu file \"{}\"\n", menuFilePath); + con::error("Could not read menu file \"{}\"", menuFilePath); return false; } @@ -134,12 +135,12 @@ namespace for (const auto& menu : parsingResult.m_menus) totalItemCount += static_cast(menu->m_items.size()); - std::cout << std::format("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)\n", - fileName, - menuLoadCount, - menuCount, - functionCount, - totalItemCount); + con::info("Successfully read menu file \"{}\" ({} loads, {} menus, {} functions, {} items)", + fileName, + menuLoadCount, + menuCount, + functionCount, + totalItemCount); // Add all functions to the zone state to make them available for all menus to be converted for (auto& function : parsingResult.m_functions) @@ -160,7 +161,7 @@ namespace converter->ConvertMenu(*commonMenu, *menuAsset, menuRegistration); if (menuAsset == nullptr) { - std::cerr << std::format("Failed to convert menu file \"{}\"\n", commonMenu->m_name); + con::error("Failed to convert menu file \"{}\"", commonMenu->m_name); return false; } diff --git a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp index fe67715a..e042ca7d 100644 --- a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp +++ b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp @@ -2,6 +2,7 @@ #include "Game/IW5/IW5.h" #include "Pool/GlobalAssetPool.h" +#include "Utils/Logging/Log.h" #include #include @@ -57,7 +58,7 @@ namespace if (ret != Z_STREAM_END) { - std::cerr << std::format("Deflate failed for loading rawfile \"{}\"\n", assetName); + con::error("Deflate failed for loading rawfile \"{}\"", assetName); deflateEnd(&zs); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp index 5e64f0a3..ca9973fd 100644 --- a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp +++ b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp @@ -2,6 +2,7 @@ #include "Game/IW5/IW5.h" #include "Pool/GlobalAssetPool.h" +#include "Utils/Logging/Log.h" #include #include @@ -53,13 +54,13 @@ namespace if (scriptFile->compressedLen <= 0 || scriptFile->bytecodeLen <= 0) { - std::cerr << std::format("Error: Invalid length of the buffers in {} specified\n", assetName); + con::error("Invalid length of the buffers in {} specified", assetName); return AssetCreationResult::Failure(); } if (offset + static_cast(scriptFile->compressedLen + scriptFile->bytecodeLen) > static_cast(file.m_length)) { - std::cerr << std::format("Error: Specified length in {} GSC BIN structure exceeds the actual file size\n", assetName); + con::error("Specified length in {} GSC BIN structure exceeds the actual file size", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp index 19f5d7c7..a9902318 100644 --- a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp @@ -4,6 +4,7 @@ #include "Game/IW5/ObjConstantsIW5.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderWeaponIW5.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read weapon gdt entry: \"{}\"\n", assetName); + con::error("Failed to read weapon gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp index aaaa6c27..7a6617fb 100644 --- a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp @@ -3,6 +3,7 @@ #include "Game/IW5/IW5.h" #include "Game/IW5/InfoString/InfoStringToStructConverter.h" #include "Game/IW5/Weapon/WeaponFields.h" +#include "Utils/Logging/Log.h" #include "Weapon/AccuracyGraphLoader.h" #include @@ -22,13 +23,13 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse hide tags as array\n"; + con::error("Failed to parse hide tags as array"); return false; } if (valueArray.size() > std::extent_v) { - std::cerr << std::format("Cannot have more than {} hide tags!\n", std::extent_v); + con::error("Cannot have more than {} hide tags!", std::extent_v); return false; } @@ -83,14 +84,13 @@ namespace std::vector> pairs; if (!ParseAsArray(value, pairs)) { - std::cerr << std::format("Failed to parse notetrack{}map as pairs\n", mapName); + con::error("Failed to parse notetrack{}map as pairs", mapName); return false; } if (pairs.size() > std::extent_v) { - std::cerr << std::format( - "Cannot have more than {} notetrack{}map entries!\n", std::extent_v, mapName); + con::error("Cannot have more than {} notetrack{}map entries!", std::extent_v, mapName); return false; } @@ -146,7 +146,7 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse attachments as array\n"; + con::error("Failed to parse attachments as array"); return false; } @@ -165,7 +165,7 @@ namespace { if (currentScope >= std::extent_v) { - std::cerr << std::format("Cannot have more than {} scopes\n", std::extent_v); + con::error("Cannot have more than {} scopes", std::extent_v); return false; } @@ -175,7 +175,7 @@ namespace { if (currentUnderBarrel >= std::extent_v) { - std::cerr << std::format("Cannot have more than {} under barrels\n", std::extent_v); + con::error("Cannot have more than {} under barrels", std::extent_v); return false; } @@ -185,7 +185,7 @@ namespace { if (currentOther >= std::extent_v) { - std::cerr << std::format("Cannot have more than {} other attachments\n", std::extent_v); + con::error("Cannot have more than {} other attachments", std::extent_v); return false; } @@ -201,7 +201,7 @@ namespace std::vector> valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse anim overrides as array\n"; + con::error("Failed to parse anim overrides as array"); return false; } @@ -242,7 +242,7 @@ namespace std::vector> valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse sound overrides as array\n"; + con::error("Failed to parse sound overrides as array"); return false; } @@ -277,7 +277,7 @@ namespace std::vector> valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse attachments as array\n"; + con::error("Failed to parse attachments as array"); return false; } @@ -315,7 +315,7 @@ namespace std::vector> valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse reload overrides as array\n"; + con::error("Failed to parse reload overrides as array"); return false; } @@ -349,7 +349,7 @@ namespace std::vector> valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse note track overrides as array\n"; + con::error("Failed to parse note track overrides as array"); return false; } @@ -378,7 +378,7 @@ namespace if (currentOverrideKeyOffset >= 24u) { - std::cerr << std::format("Cannot have more than {} note track overrides per attachment\n", 24u); + con::error("Cannot have more than {} note track overrides per attachment", 24u); return false; } @@ -433,7 +433,7 @@ namespace } } - std::cerr << std::format("Weapon does not have attachment \"{}\"\n", value); + con::error("Weapon does not have attachment \"{}\"", value); return false; } @@ -473,7 +473,7 @@ namespace auto* fxInfo = m_context.LoadDependency(value); if (!fxInfo) { - std::cerr << std::format("Failed to load fx for override \"{}\"\n", value); + con::error("Failed to load fx for override \"{}\"", value); return false; } @@ -494,7 +494,7 @@ namespace } } - std::cerr << std::format("Unknown anim file \"{}\"\n", value); + con::error("Unknown anim file \"{}\"", value); return false; } @@ -509,7 +509,7 @@ namespace } } - std::cerr << std::format("Unknown sound type \"{}\"\n", value); + con::error("Unknown sound type \"{}\"", value); return false; } @@ -524,7 +524,7 @@ namespace } } - std::cerr << std::format("Unknown fx type \"{}\"\n", value); + con::error("Unknown fx type \"{}\"", value); return false; } @@ -535,7 +535,7 @@ namespace if (size != value.size()) { - std::cerr << std::format("Invalid int value: \"{}\"\n", value); + con::error("Invalid int value: \"{}\"", value); return false; } @@ -697,28 +697,27 @@ namespace void CheckProjectileValues(const WeaponCompleteDef& weaponCompleteDef, const WeaponDef& weaponDef) { if (weaponDef.iProjectileSpeed <= 0) - std::cerr << std::format("Projectile speed for WeapType {} must be greater than 0.0", weaponCompleteDef.szDisplayName); + con::error("Projectile speed for WeapType {} must be greater than 0.0", weaponCompleteDef.szDisplayName); if (weaponDef.destabilizationCurvatureMax >= 1000000000.0f || weaponDef.destabilizationCurvatureMax < 0.0f) - std::cerr << std::format("Destabilization angle for for WeapType {} must be between 0 and 45 degrees", weaponCompleteDef.szDisplayName); + con::error("Destabilization angle for for WeapType {} must be between 0 and 45 degrees", weaponCompleteDef.szDisplayName); if (weaponDef.destabilizationRateTime < 0.0f) - std::cerr << std::format("Destabilization rate time for for WeapType {} must be non-negative", weaponCompleteDef.szDisplayName); + con::error("Destabilization rate time for for WeapType {} must be non-negative", weaponCompleteDef.szDisplayName); } void CheckTurretBarrelSpin(const WeaponCompleteDef& weaponCompleteDef, const WeaponDef& weaponDef) { if (weaponDef.weapClass != WEAPCLASS_TURRET) - std::cerr << std::format("Rotating barrel set for non-turret weapon {}.", weaponCompleteDef.szInternalName); + con::error("Rotating barrel set for non-turret weapon {}.", weaponCompleteDef.szInternalName); if (0.0f == weaponDef.turretBarrelSpinSpeed) { - std::cerr << std::format( - "Rotating barrel spin speed '{}' is invalid for weapon {}.", weaponDef.turretBarrelSpinSpeed, weaponCompleteDef.szInternalName); + con::error("Rotating barrel spin speed '{}' is invalid for weapon {}.", weaponDef.turretBarrelSpinSpeed, weaponCompleteDef.szInternalName); } if (0.0f < weaponDef.turretOverheatUpRate && 0.0f >= weaponDef.turretOverheatDownRate) { - std::cerr << std::format("Turret overheat Up rate is set, but the down rate '{}' is invalid for weapon {}.", - weaponDef.turretOverheatDownRate, - weaponCompleteDef.szInternalName); + con::error("Turret overheat Up rate is set, but the down rate '{}' is invalid for weapon {}.", + weaponDef.turretOverheatDownRate, + weaponCompleteDef.szInternalName); } } @@ -726,18 +725,18 @@ namespace { if (0.0f != weaponDef.fAdsZoomInFrac) { - std::cerr << std::format("Weapon {} ({}) has thermal scope set. ADS Zoom In frac should be 0 to prevent zoom-in blur ({}).\n", - weaponCompleteDef.szInternalName, - weaponCompleteDef.szDisplayName, - weaponDef.fAdsZoomInFrac); + con::error("Weapon {} ({}) has thermal scope set. ADS Zoom In frac should be 0 to prevent zoom-in blur ({}).", + weaponCompleteDef.szInternalName, + weaponCompleteDef.szDisplayName, + weaponDef.fAdsZoomInFrac); } if (0.0f != weaponDef.fAdsZoomOutFrac) { - std::cerr << std::format("Weapon {} ({}) has thermal scope set. ADS Zoom Out frac should be 0 to prevent zoom-out blur ({}).\n", - weaponCompleteDef.szInternalName, - weaponCompleteDef.szDisplayName, - weaponDef.fAdsZoomOutFrac); + con::error("Weapon {} ({}) has thermal scope set. ADS Zoom Out frac should be 0 to prevent zoom-out blur ({}).", + weaponCompleteDef.szInternalName, + weaponCompleteDef.szDisplayName, + weaponDef.fAdsZoomOutFrac); } } @@ -767,7 +766,7 @@ namespace weaponDef.fMinDamageRange = 999999.12f; if (weaponDef.enemyCrosshairRange > 15000.0f) - std::cerr << std::format("Enemy crosshair ranges should be less than {}\n", 15000.0f); + con::error("Enemy crosshair ranges should be less than {}", 15000.0f); if (weaponDef.weapType == WEAPTYPE_PROJECTILE) CheckProjectileValues(weaponCompleteDef, weaponDef); @@ -780,22 +779,21 @@ namespace if (weaponDef.offhandClass && !weaponDef.bClipOnly) { - std::cerr << std::format( - "Weapon {} ({}) is an offhand weapon but is not set to clip only, which is not supported since we can't reload the offhand slot.\n", - weaponCompleteDef.szInternalName, - weaponCompleteDef.szDisplayName); + con::error("Weapon {} ({}) is an offhand weapon but is not set to clip only, which is not supported since we can't reload the offhand slot.", + weaponCompleteDef.szInternalName, + weaponCompleteDef.szDisplayName); } if (weaponDef.weapType == WEAPTYPE_BULLET) { if (weaponDef.bulletExplDmgMult <= 0.0f) - std::cerr << std::format("Detected invalid bulletExplDmgMult of '{}' for weapon '{}'; please update weapon settings.\n", - weaponDef.bulletExplDmgMult, - weaponCompleteDef.szInternalName); + con::error("Detected invalid bulletExplDmgMult of '{}' for weapon '{}'; please update weapon settings.", + weaponDef.bulletExplDmgMult, + weaponCompleteDef.szInternalName); if (weaponDef.bulletExplRadiusMult <= 0.0f) - std::cerr << std::format("Detected invalid bulletExplRadiusMult of '{}' for weapon '{}'; please update weapon settings.\n", - weaponDef.bulletExplRadiusMult, - weaponCompleteDef.szInternalName); + con::error("Detected invalid bulletExplRadiusMult of '{}' for weapon '{}'; please update weapon settings.", + weaponDef.bulletExplRadiusMult, + weaponCompleteDef.szInternalName); } } @@ -878,7 +876,7 @@ namespace weapon infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); + con::error("Failed to parse weapon: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp index 492baea4..b04cdc78 100644 --- a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp @@ -2,6 +2,7 @@ #include "Game/IW5/IW5.h" #include "Game/IW5/Weapon/JsonWeaponAttachment.h" +#include "Utils/Logging/Log.h" #include "Weapon/AttachmentCommon.h" #include @@ -39,7 +40,7 @@ namespace if (type != "attachment" || version != 1u) { - std::cerr << "Tried to load attachment \"" << attachment.szInternalName << "\" but did not find expected type attachment of version 1\n"; + con::error("Tried to load attachment \"{}\" but did not find expected type attachment of version 1", attachment.szInternalName); return false; } @@ -48,7 +49,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of attachment: {}\n", e.what()); + con::error("Failed to parse json of attachment: {}", e.what()); } return false; @@ -57,7 +58,7 @@ namespace private: static void PrintError(const WeaponAttachment& attachment, const std::string& message) { - std::cerr << "Cannot load attachment \"" << attachment.szInternalName << "\": " << message << "\n"; + con::error("Cannot load attachment \"{}\": {}", attachment.szInternalName, message); } bool CreateWeaponAttachmentFromJson(const JsonWeaponAttachment& jAttachment, WeaponAttachment& attachment) const @@ -653,7 +654,7 @@ namespace const JsonLoader loader(*file.m_stream, m_memory, context, registration); if (!loader.Load(*attachment)) { - std::cerr << std::format("Failed to load attachment \"{}\"\n", assetName); + con::error("Failed to load attachment \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp index 8d30bf2a..c2a7c16a 100644 --- a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp @@ -4,6 +4,7 @@ #include "Game/IW5/ObjConstantsIW5.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderWeaponIW5.h" +#include "Utils/Logging/Log.h" #include "Weapon/WeaponCommon.h" #include @@ -34,7 +35,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp index 093f5e04..44469186 100644 --- a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp +++ b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp @@ -3,6 +3,7 @@ #include "Game/T5/Material/JsonMaterialLoaderT5.h" #include "Game/T5/T5.h" #include "Material/MaterialCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -32,7 +33,7 @@ namespace AssetRegistration registration(assetName, material); if (!LoadMaterialAsJson(*file.m_stream, *material, m_memory, context, registration)) { - std::cerr << std::format("Failed to load material \"{}\"\n", assetName); + con::error("Failed to load material \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp index f261f06f..4a49a980 100644 --- a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp +++ b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp @@ -1,6 +1,7 @@ #include "LoaderRawFileT5.h" #include "Game/T5/T5.h" +#include "Utils/Logging/Log.h" #include #include @@ -71,7 +72,7 @@ namespace if (ret != Z_STREAM_END) { - std::cerr << std::format("Deflate failed for loading gsc file \"{}\"\n", assetName); + con::error("Deflate failed for loading gsc file \"{}\"", assetName); deflateEnd(&zs); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp index 4d135cf3..0df26bc3 100644 --- a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp +++ b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp @@ -3,6 +3,7 @@ #include "Csv/CsvStream.h" #include "Game/T6/CommonT6.h" #include "Game/T6/T6.h" +#include "Utils/Logging/Log.h" #include #include @@ -65,14 +66,14 @@ namespace if (currentRow.size() < COL_COUNT_MIN) { - std::cerr << std::format("{} Column count lower than min column count ({})\n", ErrorPrefix(assetName, currentRowIndex), COL_COUNT_MIN); + con::error("{} Column count lower than min column count ({})", ErrorPrefix(assetName, currentRowIndex), COL_COUNT_MIN); return AssetCreationResult::Failure(); } int index; if (!ParseInt(index, currentRow[ROW_INDEX]) || index < 0) { - std::cerr << std::format("{} Failed to parse index\n", ErrorPrefix(assetName, currentRowIndex)); + con::error("{} Failed to parse index", ErrorPrefix(assetName, currentRowIndex)); return AssetCreationResult::Failure(); } @@ -118,7 +119,7 @@ namespace } else { - std::cerr << std::format("{} Unknown row type \"{}\"\n", ErrorPrefix(assetName, currentRowIndex), currentRow[ROW_TYPE]); + con::error("{} Unknown row type \"{}\"", ErrorPrefix(assetName, currentRowIndex), currentRow[ROW_TYPE]); return AssetCreationResult::Failure(); } } @@ -222,26 +223,26 @@ namespace { if (row.size() < COL_COUNT_ICON) { - std::cerr << std::format("{} Column count lower than min column count for entries ({})\n", ErrorPrefix(assetName, rowIndex), COL_COUNT_ICON); + con::error("{} Column count lower than min column count for entries ({})", ErrorPrefix(assetName, rowIndex), COL_COUNT_ICON); return false; } if (!ParseInt(icon.fontIconSize, row[ROW_ICON_SIZE])) { - std::cerr << std::format("{} Failed to parse size\n", ErrorPrefix(assetName, rowIndex)); + con::error("{} Failed to parse size", ErrorPrefix(assetName, rowIndex)); return false; } if (!ParseFloat(icon.xScale, row[ROW_ICON_XSCALE]) || !ParseFloat(icon.yScale, row[ROW_ICON_YSCALE])) { - std::cerr << std::format("{} Failed to parse scale\n", ErrorPrefix(assetName, rowIndex)); + con::error("{} Failed to parse scale", ErrorPrefix(assetName, rowIndex)); return false; } auto* materialDependency = context.LoadDependency(row[ROW_ICON_MATERIAL]); if (materialDependency == nullptr) { - std::cerr << std::format("{} Failed to load material \"{}\"\n", ErrorPrefix(assetName, rowIndex), row[ROW_ICON_MATERIAL]); + con::error("{} Failed to load material \"{}\"", ErrorPrefix(assetName, rowIndex), row[ROW_ICON_MATERIAL]); return false; } registration.AddDependency(materialDependency); @@ -258,19 +259,19 @@ namespace { if (row.size() < COL_COUNT_ALIAS) { - std::cerr << std::format("{} Column count lower than min column count for aliases ({})\n", ErrorPrefix(assetName, rowIndex), COL_COUNT_ALIAS); + con::error("{} Column count lower than min column count for aliases ({})", ErrorPrefix(assetName, rowIndex), COL_COUNT_ALIAS); return false; } if (!ParseHashStr(alias.aliasHash, row[ROW_ALIAS_NAME])) { - std::cerr << std::format("{} Failed to parse alias \"{}\"\n", ErrorPrefix(assetName, rowIndex), row[ROW_ALIAS_NAME]); + con::error("{} Failed to parse alias \"{}\"", ErrorPrefix(assetName, rowIndex), row[ROW_ALIAS_NAME]); return false; } if (!ParseHashStr(alias.buttonHash, row[ROW_ALIAS_BUTTON])) { - std::cerr << std::format("{} Failed to parse button \"{}\"\n", ErrorPrefix(assetName, rowIndex), row[ROW_ALIAS_BUTTON]); + con::error("{} Failed to parse button \"{}\"", ErrorPrefix(assetName, rowIndex), row[ROW_ALIAS_BUTTON]); return false; } diff --git a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp index fe909307..01dc5698 100644 --- a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp +++ b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/CommonT6.h" #include "Game/T6/FontIcon/JsonFontIconT6.h" #include "Game/T6/T6.h" +#include "Utils/Logging/Log.h" #include #include @@ -45,7 +46,7 @@ namespace if (type != "font-icon" || version != 1u) { - std::cerr << std::format("Tried to load font icon \"{}\" but did not find expected type font-icon of version 1\n", assetName); + con::error("Tried to load font icon \"{}\" but did not find expected type font-icon of version 1", assetName); return AssetCreationResult::Failure(); } @@ -55,7 +56,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of font icon: {}\n", e.what()); + con::error("Failed to parse json of font icon: {}", e.what()); } return AssetCreationResult::Failure(); @@ -114,7 +115,7 @@ namespace auto* materialDependency = context.LoadDependency(jFontIconEntry.material); if (materialDependency == nullptr) { - std::cerr << std::format("Failed to load material \"{}\" for font icon entry \"{}\"\n", jFontIconEntry.material, jFontIconEntry.name); + con::error("Failed to load material \"{}\" for font icon entry \"{}\"", jFontIconEntry.material, jFontIconEntry.name); return false; } registration.AddDependency(materialDependency); diff --git a/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp b/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp index 0c618792..e870761c 100644 --- a/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp +++ b/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "Image/ImageCommon.h" #include "Image/IwiLoader.h" +#include "Utils/Logging/Log.h" #include #include @@ -40,7 +41,7 @@ namespace const auto texture = iwi::LoadIwi(ss); if (!texture) { - std::cerr << std::format("Failed to load texture from: {}\n", fileName); + con::error("Failed to load texture from: {}", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp index d7fd2678..1338bb2c 100644 --- a/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp +++ b/src/ObjLoading/Game/T6/InfoString/InfoStringToStructConverter.cpp @@ -1,6 +1,7 @@ #include "InfoStringToStructConverter.h" #include "Game/T6/CommonT6.h" +#include "Utils/Logging/Log.h" #include #include @@ -83,7 +84,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (fx == nullptr) { - std::cerr << std::format("Failed to load fx asset \"{}\"\n", value); + con::error("Failed to load fx asset \"{}\"", value); return false; } @@ -105,7 +106,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (xmodel == nullptr) { - std::cerr << std::format("Failed to load xmodel asset \"{}\"\n", value); + con::error("Failed to load xmodel asset \"{}\"", value); return false; } @@ -128,7 +129,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (material == nullptr) { - std::cerr << std::format("Failed to load material asset \"{}\"\n", value); + con::error("Failed to load material asset \"{}\"", value); return false; } @@ -150,7 +151,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (physPreset == nullptr) { - std::cerr << std::format("Failed to load physpreset asset \"{}\"\n", value); + con::error("Failed to load physpreset asset \"{}\"", value); return false; } @@ -175,7 +176,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons if (tracer == nullptr) { - std::cerr << std::format("Failed to load tracer asset \"{}\"\n", value); + con::error("Failed to load tracer asset \"{}\"", value); return false; } @@ -190,7 +191,7 @@ bool InfoStringToStructConverter::ConvertBaseField(const cspField_t& field, cons unsigned int soundAliasHash; if (!GetHashValue(value, soundAliasHash)) { - std::cerr << std::format("Failed to parse value \"{}\" as hash\n", value); + con::error("Failed to parse value \"{}\" as hash", value); return false; } diff --git a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp index 3a8415ec..65c71ce3 100644 --- a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp +++ b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/Leaderboard/JsonLeaderboardDef.h" #include "Game/T6/T6.h" #include "Leaderboard/LeaderboardCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -37,7 +38,7 @@ namespace if (type != "leaderboard" || version != 1u) { - std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); + con::error("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1", leaderboardDef.name); return false; } @@ -46,7 +47,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); + con::error("Failed to parse json of leaderboard: {}", e.what()); } return false; @@ -149,7 +150,7 @@ namespace const JsonLoader loader(*file.m_stream, m_memory); if (!loader.Load(*leaderboardDef)) { - std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); + con::error("Failed to load leaderboard \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp index 82e3649b..8f6bd9c4 100644 --- a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp +++ b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/Material/JsonMaterialLoaderT6.h" #include "Game/T6/T6.h" #include "Material/MaterialCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -32,7 +33,7 @@ namespace AssetRegistration registration(assetName, material); if (!LoadMaterialAsJson(*file.m_stream, *material, m_memory, context, registration)) { - std::cerr << std::format("Failed to load material \"{}\"\n", assetName); + con::error("Failed to load material \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 9281a38b..796278d6 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -30,6 +30,7 @@ #include "StringTable/LoaderStringTableT6.h" #include "Tracer/GdtLoaderTracerT6.h" #include "Tracer/RawLoaderTracerT6.h" +#include "Utils/Logging/Log.h" #include "Vehicle/GdtLoaderVehicleT6.h" #include "Vehicle/RawLoaderVehicleT6.h" #include "Weapon/AttachmentGdtLoaderT6.h" @@ -62,14 +63,12 @@ namespace T6 SoundBank* ObjLoader::LoadSoundBankForZone(ISearchPath& searchPath, const std::string& soundBankFileName, Zone& zone) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Trying to load sound bank '{}' for zone '{}'\n", soundBankFileName, zone.m_name); + con::debug("Trying to load sound bank '{}' for zone '{}'", soundBankFileName, zone.m_name); auto* existingSoundBank = SoundBank::Repository.GetContainerByName(soundBankFileName); if (existingSoundBank != nullptr) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Referencing loaded sound bank '{}'.\n", soundBankFileName); + con::debug("Referencing loaded sound bank '{}'.", soundBankFileName); SoundBank::Repository.AddContainerReference(existingSoundBank, &zone); return existingSoundBank; @@ -83,19 +82,18 @@ namespace T6 if (!sndBank->Initialize()) { - std::cerr << std::format("Failed to load sound bank '{}'\n", soundBankFileName); + con::error("Failed to load sound bank '{}'", soundBankFileName); return nullptr; } SoundBank::Repository.AddContainer(std::move(sndBank), &zone); - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Found and loaded sound bank '{}'\n", soundBankFileName); + con::debug("Found and loaded sound bank '{}'", soundBankFileName); return sndBankPtr; } - std::cerr << std::format("Failed to load sound bank '{}'\n", soundBankFileName); + con::error("Failed to load sound bank '{}'", soundBankFileName); return nullptr; } @@ -113,7 +111,7 @@ namespace T6 if (soundBank) { if (!VerifySoundBankChecksum(*soundBank, sndBankLinkedInfo)) - std::cout << std::format("Checksum of sound bank does not match link time checksum for '{}'\n", soundBankFileName); + con::warn("Checksum of sound bank does not match link time checksum for '{}'", soundBankFileName); loadedBanksForZone.emplace(soundBankFileName); @@ -163,14 +161,12 @@ namespace T6 void ObjLoader::LoadIPakForZone(ISearchPath& searchPath, const std::string& ipakName, Zone& zone) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Trying to load ipak '{}' for zone '{}'\n", ipakName, zone.m_name); + con::debug("Trying to load ipak '{}' for zone '{}'", ipakName, zone.m_name); auto* existingIPak = IIPak::Repository.GetContainerByName(ipakName); if (existingIPak != nullptr) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Referencing loaded ipak '{}'.\n", ipakName); + con::debug("Referencing loaded ipak '{}'.", ipakName); IIPak::Repository.AddContainerReference(existingIPak, &zone); return; @@ -187,12 +183,11 @@ namespace T6 { IIPak::Repository.AddContainer(std::move(ipak), &zone); - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Found and loaded ipak '{}'.\n", ipakFilename); + con::debug("Found and loaded ipak '{}'.", ipakFilename); } else { - std::cerr << std::format("Failed to load ipak '{}'!\n", ipakFilename); + con::error("Failed to load ipak '{}'!", ipakFilename); } } } @@ -209,8 +204,7 @@ namespace T6 void ObjLoader::LoadCommonIPaks(ISearchPath& searchPath, Zone& zone) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Loading common ipaks for zone \"{}\"\n", zone.m_name); + con::debug("Loading common ipaks for zone \"{}\"", zone.m_name); LoadIPakForZone(searchPath, "base", zone); const auto& languagePrefixes = IGame::GetGameById(GameId::T6)->GetLanguagePrefixes(); @@ -219,23 +213,20 @@ namespace T6 if (IsMpZone(zone)) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Loading multiplayer ipaks for zone \"{}\"\n", zone.m_name); + con::debug("Loading multiplayer ipaks for zone \"{}\"", zone.m_name); LoadIPakForZone(searchPath, "mp", zone); LoadIPakForZone(searchPath, "so", zone); } else if (IsZmZone(zone)) { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Loading zombie ipak for zone \"{}\"\n", zone.m_name); + con::debug("Loading zombie ipak for zone \"{}\"", zone.m_name); LoadIPakForZone(searchPath, "zm", zone); } else { - if (ObjLoading::Configuration.Verbose) - std::cout << std::format("Loading singleplayer ipak for zone \"{}\"\n", zone.m_name); + con::debug("Loading singleplayer ipak for zone \"{}\"", zone.m_name); LoadIPakForZone(searchPath, "sp", zone); } diff --git a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp index 3b033248..f6aa1df0 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysConstraintsT6.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read phys constraints gdt entry: \"{}\"\n", assetName); + con::error("Failed to read phys constraints gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp index 525d9771..69d071be 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/PhysConstraints/PhysConstraintsFields.h" #include "Game/T6/T6.h" +#include "Utils/Logging/Log.h" #include #include @@ -101,7 +102,7 @@ namespace phys_constraints std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse phys constraints: \"{}\"\n", assetName); + con::error("Failed to parse phys constraints: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp index a4edbb53..f26a8f45 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp @@ -5,6 +5,7 @@ #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysConstraintsT6.h" #include "PhysConstraints/PhysConstraintsCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp index 36679dab..c8e6493e 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysPresetT6.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read phys preset gdt entry: \"{}\"\n", assetName); + con::error("Failed to read phys preset gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp index 6e996ad1..647f2353 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/PhysPreset/PhysPresetFields.h" #include "Game/T6/T6.h" +#include "Utils/Logging/Log.h" #include #include @@ -87,7 +88,7 @@ namespace phys_preset std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName); + con::error("Failed to parse phys preset: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp index 46430470..bfd2e12c 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp @@ -5,6 +5,7 @@ #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysPresetT6.h" #include "PhysPreset/PhysPresetCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp index 8782da60..37a6cf31 100644 --- a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp +++ b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp @@ -2,6 +2,7 @@ #include "Game/T6/T6.h" #include "Pool/GlobalAssetPool.h" +#include "Utils/Logging/Log.h" #include #include @@ -73,7 +74,7 @@ namespace if (ret != Z_STREAM_END) { - std::cerr << std::format("Deflate failed for loading animtree file \"{}\"\n", assetName); + con::error("Deflate failed for loading animtree file \"{}\"", assetName); deflateEnd(&zs); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp index 9b9b3781..3626b210 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp @@ -7,6 +7,7 @@ #include "Game/T6/T6.h" #include "ObjContainer/SoundBank/SoundBankWriter.h" #include "Pool/GlobalAssetPool.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -96,14 +97,14 @@ namespace if (!cell.AsFloat(dbsplValue)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - Must be a float\n", rowIndex + 1, colName); + con::error("Invalid value for row {} col '{}' - Must be a float", rowIndex + 1, colName); return false; } if (dbsplValue < 0.0f || dbsplValue > 100.0f) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [0.0, 100.0]\n", rowIndex + 1, colName, dbsplValue); + con::error("Invalid value for row {} col '{}' - {} [0.0, 100.0]", rowIndex + 1, colName, dbsplValue); return false; } @@ -121,14 +122,14 @@ namespace if (!cell.AsFloat(centsValue)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - Must be a float\n", rowIndex + 1, colName); + con::error("Invalid value for row {} col '{}' - Must be a float", rowIndex + 1, colName); return false; } if (centsValue < -2400.0f || centsValue > 1200.0f) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [-2400.0, 1200.0]\n", rowIndex + 1, colName, centsValue); + con::error("Invalid value for row {} col '{}' - {} [-2400.0, 1200.0]", rowIndex + 1, colName, centsValue); return false; } @@ -151,14 +152,14 @@ namespace if (!cell.AsUInt32(value32)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - Must be a uint\n", rowIndex + 1, colName); + con::error("Invalid value for row {} col '{}' - Must be a uint", rowIndex + 1, colName); return false; } if (value32 < min || value32 > max) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [{}, {}]\n", rowIndex + 1, colName, value32, min, max); + con::error("Invalid value for row {} col '{}' - {} [{}, {}]", rowIndex + 1, colName, value32, min, max); return false; } @@ -181,14 +182,14 @@ namespace if (!cell.AsInt32(value32)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - Must be a int\n", rowIndex + 1, colName); + con::error("Invalid value for row {} col '{}' - Must be a int", rowIndex + 1, colName); return false; } if (value32 < min || value32 > max) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [{}, {}]\n", rowIndex + 1, colName, value32, min, max); + con::error("Invalid value for row {} col '{}' - {} [{}, {}]", rowIndex + 1, colName, value32, min, max); return false; } @@ -211,14 +212,14 @@ namespace if (!cell.AsUInt32(value32)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - Must be a uint\n", rowIndex + 1, colName); + con::error("Invalid value for row {} col '{}' - Must be a uint", rowIndex + 1, colName); return false; } if (value32 < min || value32 > max) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [{}, {}]\n", rowIndex + 1, colName, value32, min, max); + con::error("Invalid value for row {} col '{}' - {} [{}, {}]", rowIndex + 1, colName, value32, min, max); return false; } @@ -235,14 +236,14 @@ namespace if (!cell.AsFloat(valueFloat)) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - Must be a float\n", rowIndex + 1, colName); + con::error("Invalid value for row {} col '{}' - Must be a float", rowIndex + 1, colName); return false; } if (valueFloat < 0.0f || valueFloat > 1.0f) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {} [0.0, 1.0]\n", rowIndex + 1, colName, valueFloat); + con::error("Invalid value for row {} col '{}' - {} [0.0, 1.0]", rowIndex + 1, colName, valueFloat); return false; } @@ -290,9 +291,9 @@ namespace } const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {}. Must be one of:\n", rowIndex + 1, colName, cell.m_value); + con::error("Invalid value for row {} col '{}' - {}. Must be one of:", rowIndex + 1, colName, cell.m_value); for (auto i = 0u; i < enumValueCount; i++) - std::cerr << std::format(" {}\n", enumValues[i]); + con::error(" {}", enumValues[i]); return false; } @@ -341,9 +342,9 @@ namespace if (!foundValue) { const auto& colName = headerRow.HeaderNameForColumn(columnIndex); - std::cerr << std::format("Invalid value for row {} col '{}' - {}. Must be one of:\n", rowIndex + 1, colName, entry); + con::error("Invalid value for row {} col '{}' - {}. Must be one of:", rowIndex + 1, colName, entry); for (auto i = 0u; i < enumValueCount; i++) - std::cerr << std::format(" {}\n", enumValues[i]); + con::error(" {}", enumValues[i]); return false; } } @@ -648,7 +649,7 @@ namespace SoundAliasHeaders headers; if (!headerRow.Read(csv) || !headers.From(headerRow)) { - std::cerr << std::format("Invalid headers for aliases of sound bank {}\n", sndBank->name); + con::error("Invalid headers for aliases of sound bank {}", sndBank->name); return false; } @@ -740,7 +741,7 @@ namespace if (freeIdx == std::numeric_limits::max()) { - std::cerr << "Unable to allocate sound bank alias index list\n"; + con::error("Unable to allocate sound bank alias index list"); return false; } @@ -807,7 +808,7 @@ namespace RadverbHeaders headers; if (!csvHeaders.Read(csv) || !headers.From(csvHeaders)) { - std::cerr << std::format("Invalid headers for radverbs of sound bank {}\n", sndBank->name); + con::error("Invalid headers for radverbs of sound bank {}", sndBank->name); return false; } @@ -867,7 +868,7 @@ namespace const auto nameRow = headerRow.GetIndexForHeader("name"); if (!nameRow) { - std::cerr << std::format("Missing name header for ducks of sound bank {}\n", sndBank->name); + con::error("Missing name header for ducks of sound bank {}", sndBank->name); return false; } @@ -882,7 +883,7 @@ namespace const auto duckFile = searchPath.Open(std::format("soundbank/ducks/{}.duk", name)); if (!duckFile.IsOpen()) { - std::cerr << std::format("Unable to find .duk file for {} in ducklist for sound bank {}\n", name, sndBank->name); + con::error("Unable to find .duk file for {} in ducklist for sound bank {}", name, sndBank->name); return false; } @@ -944,7 +945,7 @@ namespace { if (assetName.find('.') == std::string::npos) { - std::cerr << "A language must be specific in the sound bank asset name! (Ex: mpl_common.all)\n"; + con::error("A language must be specific in the sound bank asset name! (Ex: mpl_common.all)"); return AssetCreationResult::Failure(); } @@ -969,7 +970,7 @@ namespace { if (!LoadSoundRadverbs(m_memory, sndBank, radverbFile)) { - std::cerr << std::format("Sound bank reverbs file for {} is invalid\n", assetName); + con::error("Sound bank reverbs file for {} is invalid", assetName); return AssetCreationResult::Failure(); } } @@ -979,7 +980,7 @@ namespace { if (!LoadSoundDuckList(m_search_path, m_memory, sndBank, duckListFile)) { - std::cerr << std::format("Sound bank ducklist file for {} is invalid\n", assetName); + con::error("Sound bank ducklist file for {} is invalid", assetName); return AssetCreationResult::Failure(); } } @@ -1051,7 +1052,7 @@ namespace } else { - std::cerr << std::format("Loaded sound bank for {} failed to generate. Please check your build files.\n", assetName); + con::error("Loaded sound bank for {} failed to generate. Please check your build files.", assetName); return AssetCreationResult::Failure(); } } @@ -1065,7 +1066,7 @@ namespace if (!result) { - std::cerr << std::format("Streamed sound bank for {} failed to generate. Please check your build files.\n", assetName); + con::error("Streamed sound bank for {} failed to generate. Please check your build files.", assetName); return AssetCreationResult::Failure(); } } diff --git a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp index 7cad238c..fa4ba6a4 100644 --- a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderTracerT6.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read tracer gdt entry: \"{}\"\n", assetName); + con::error("Failed to read tracer gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp index e7bc4377..bcd0ea47 100644 --- a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "Game/T6/Tracer/TracerFields.h" #include "Tracer/TracerCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -67,7 +68,7 @@ namespace tracer infoString, *tracer, m_zone.m_script_strings, m_memory, context, registration, tracer_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse tracer: \"{}\"\n", assetName); + con::error("Failed to parse tracer: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp index ff3fdc42..7de94228 100644 --- a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp @@ -5,6 +5,7 @@ #include "InfoString/InfoString.h" #include "InfoStringLoaderTracerT6.h" #include "Tracer/TracerCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_TRACER, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp index e0267246..e860a9d3 100644 --- a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderVehicleT6.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read vehicle gdt entry: \"{}\"\n", assetName); + con::error("Failed to read vehicle gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp index 76f4c2ce..1dbcba3b 100644 --- a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/T6.h" #include "Game/T6/Vehicle/VehicleFields.h" +#include "Utils/Logging/Log.h" #include #include @@ -37,7 +38,7 @@ namespace if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as mph\n", value); + con::error("Failed to parse value \"{}\" as mph", value); return false; } @@ -51,7 +52,7 @@ namespace if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as pounds\n", value); + con::error("Failed to parse value \"{}\" as pounds", value); return false; } @@ -79,7 +80,7 @@ namespace } *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset) = TEAM_BAD; - std::cerr << std::format("Failed to parse value \"{}\" as team\n", value); + con::error("Failed to parse value \"{}\" as team", value); return false; } @@ -127,7 +128,7 @@ namespace vehicle infoString, *vehicleDef, m_zone.m_script_strings, m_memory, context, registration, vehicle_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse vehicle: \"{}\"\n", assetName); + con::error("Failed to parse vehicle: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp index a7b5368b..9bbd462c 100644 --- a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderVehicleT6.h" +#include "Utils/Logging/Log.h" #include "Vehicle/VehicleCommon.h" #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_VEHICLE, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp index 66a3b1d9..ac7df117 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read attachment gdt entry: \"{}\"\n", assetName); + con::error("Failed to read attachment gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp index dd296d58..b81a2dd3 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "Game/T6/Weapon/AttachmentFields.h" #include "Game/T6/Weapon/WeaponStrings.h" +#include "Utils/Logging/Log.h" #include #include @@ -113,7 +114,7 @@ namespace attachment infoString, *attachment, m_zone.m_script_strings, m_memory, context, registration, attachment_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse attachment: \"{}\"\n", assetName); + con::error("Failed to parse attachment: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp index 815694d4..dd3da8d2 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" +#include "Utils/Logging/Log.h" #include "Weapon/AttachmentCommon.h" #include @@ -34,7 +35,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp index 01a9a006..4f505ca1 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read attachment unique gdt entry: \"{}\"\n", assetName); + con::error("Failed to read attachment unique gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp index 059091a1..de1070b0 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "Game/T6/Weapon/AttachmentUniqueFields.h" #include "Game/T6/Weapon/WeaponStrings.h" +#include "Utils/Logging/Log.h" #include #include @@ -48,13 +49,13 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse hide tags as array\n"; + con::error("Failed to parse hide tags as array"); return false; } if (valueArray.size() > std::extent_v) { - std::cerr << std::format("Cannot have more than {} hide tags!\n", std::extent_v); + con::error("Cannot have more than {} hide tags!", std::extent_v); return false; } @@ -93,7 +94,7 @@ namespace if (camo == nullptr) { - std::cerr << std::format("Failed to load camo asset \"{}\"\n", value); + con::error("Failed to load camo asset \"{}\"", value); return false; } @@ -143,7 +144,7 @@ namespace std::vector attachmentsFromName; if (!attachment_unique::ExtractAttachmentsFromAssetNameT6(assetName, attachmentsFromName)) { - std::cerr << std::format("Failed to determine attachments from attachment unique name \"{}\"\n", assetName); + con::error("Failed to determine attachments from attachment unique name \"{}\"", assetName); return false; } @@ -236,7 +237,7 @@ namespace attachment_unique std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse attachment unique: \"{}\"\n", assetName); + con::error("Failed to parse attachment unique: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp index a8a11dd0..95fc13e6 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" +#include "Utils/Logging/Log.h" #include "Weapon/AttachmentUniqueCommon.h" #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp index c1a2fdbb..a649bbab 100644 --- a/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/Json/JsonWeaponCamo.h" #include "Game/T6/T6.h" #include "Pool/GlobalAssetPool.h" +#include "Utils/Logging/Log.h" #include "Weapon/CamoCommon.h" #include @@ -40,7 +41,7 @@ namespace if (type != "weaponCamo" || version != 1u) { - std::cerr << std::format("Tried to load weapon camo \"{}\" but did not find expected type weaponCamo of version {}\n", weaponCamo.name, 1u); + con::error("Tried to load weapon camo \"{}\" but did not find expected type weaponCamo of version {}", weaponCamo.name, 1u); return false; } @@ -49,7 +50,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of weapon camo: {}\n", e.what()); + con::error("Failed to parse json of weapon camo: {}", e.what()); } return false; @@ -58,7 +59,7 @@ namespace private: static void PrintError(const WeaponCamo& weaponCamo, const std::string& message) { - std::cerr << std::format("Cannot load weapon camo \"{}\": {}\n", weaponCamo.name, message); + con::error("Cannot load weapon camo \"{}\": {}", weaponCamo.name, message); } bool CreateWeaponCamoSetFromJson(const JsonWeaponCamoSet& jWeaponCamoSet, WeaponCamoSet& weaponCamoSet, const WeaponCamo& weaponCamo) const @@ -263,7 +264,7 @@ namespace const JsonLoader loader(*file.m_stream, m_memory, context, registration); if (!loader.Load(*weaponCamo)) { - std::cerr << std::format("Failed to load weapon camo \"{}\"\n", assetName); + con::error("Failed to load weapon camo \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp index 02f77115..5b9acf66 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" +#include "Utils/Logging/Log.h" #include "WeaponInfoStringLoaderT6.h" #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read weapon gdt entry: \"{}\"\n", assetName); + con::error("Failed to read weapon gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp index ccaf394e..8bc473e9 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp @@ -5,6 +5,7 @@ #include "Game/T6/T6.h" #include "Game/T6/Weapon/WeaponFields.h" #include "Game/T6/Weapon/WeaponStrings.h" +#include "Utils/Logging/Log.h" #include "Weapon/AccuracyGraphLoader.h" #include @@ -126,13 +127,13 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse hide tags as array\n"; + con::error("Failed to parse hide tags as array"); return false; } if (valueArray.size() > std::extent_v) { - std::cerr << std::format("Cannot have more than {} hide tags!\n", std::extent_v); + con::error("Cannot have more than {} hide tags!", std::extent_v); return false; } @@ -183,13 +184,13 @@ namespace std::vector> pairs; if (!ParseAsArray(value, pairs)) { - std::cerr << "Failed to parse notetracksoundmap as pairs\n"; + con::error("Failed to parse notetracksoundmap as pairs"); return false; } if (pairs.size() > std::extent_v) { - std::cerr << "Cannot have more than " << std::extent_v << " notetracksoundmap entries!\n"; + con::error("Cannot have more than {} notetracksoundmap entries!", std::extent_v); return false; } @@ -239,7 +240,7 @@ namespace if (camo == nullptr) { - std::cerr << std::format("Failed to load camo asset \"{}\"\n", value); + con::error("Failed to load camo asset \"{}\"", value); return false; } @@ -254,7 +255,7 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse attachments as array\n"; + con::error("Failed to parse attachments as array"); return false; } @@ -265,7 +266,7 @@ namespace auto* attachmentAssetInfo = m_context.ForceLoadDependency(attachmentName); if (attachmentAssetInfo == nullptr) { - std::cerr << std::format("Failed to load attachment asset \"{}\"\n", attachmentName); + con::error("Failed to load attachment asset \"{}\"", attachmentName); return false; } @@ -273,17 +274,17 @@ namespace if (static_cast(attachmentAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT) { - std::cerr << std::format( - "Invalid attachment type {} for attachment asset \"{}\"\n", static_cast(attachmentAsset->attachmentType), attachmentName); + con::error( + "Invalid attachment type {} for attachment asset \"{}\"", static_cast(attachmentAsset->attachmentType), attachmentName); return false; } if (attachments[attachmentAsset->attachmentType] != nullptr) { - std::cerr << std::format("Already loaded attachment with same type {}: \"{}\", \"{}\"\n", - static_cast(attachmentAsset->attachmentType), - attachments[attachmentAsset->attachmentType]->szInternalName, - attachmentName); + con::error("Already loaded attachment with same type {}: \"{}\", \"{}\"", + static_cast(attachmentAsset->attachmentType), + attachments[attachmentAsset->attachmentType]->szInternalName, + attachmentName); return false; } @@ -305,7 +306,7 @@ namespace std::vector valueArray; if (!ParseAsArray(value, valueArray)) { - std::cerr << "Failed to parse attachment uniques as array\n"; + con::error("Failed to parse attachment uniques as array"); return false; } @@ -317,7 +318,7 @@ namespace auto* attachmentUniqueAssetInfo = m_context.ForceLoadDependency(attachmentUniqueName); if (attachmentUniqueAssetInfo == nullptr) { - std::cerr << std::format("Failed to load attachment unique asset \"{}\"\n", attachmentUniqueName); + con::error("Failed to load attachment unique asset \"{}\"", attachmentUniqueName); return false; } @@ -327,9 +328,8 @@ namespace { if (attachmentCombinationIndex >= std::extent_v) { - std::cerr << std::format( - "Cannot have more than {} combined attachment attachment unique entries!\n", - (std::extent_v - std::extent_v)); + con::error("Cannot have more than {} combined attachment attachment unique entries!", + (std::extent_v - std::extent_v)); return false; } @@ -340,18 +340,18 @@ namespace { if (static_cast(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT) { - std::cerr << std::format("Invalid attachment type {} for attachment unique asset \"{}\"\n", - static_cast(attachmentUniqueAsset->attachmentType), - attachmentUniqueName); + con::error("Invalid attachment type {} for attachment unique asset \"{}\"", + static_cast(attachmentUniqueAsset->attachmentType), + attachmentUniqueName); return false; } if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr) { - std::cerr << std::format("Already loaded attachment unique with same type {}: \"{}\", \"{}\"\n", - static_cast(attachmentUniqueAsset->attachmentType), - attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName, - attachmentUniqueName); + con::error("Already loaded attachment unique with same type {}: \"{}\", \"{}\"", + static_cast(attachmentUniqueAsset->attachmentType), + attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName, + attachmentUniqueName); return false; } @@ -621,7 +621,7 @@ namespace weapon infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); + con::error("Failed to parse weapon: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp index 97f37dec..2ed85259 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" +#include "Utils/Logging/Log.h" #include "Weapon/WeaponCommon.h" #include "WeaponInfoStringLoaderT6.h" @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp index 09dbb255..e69244aa 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderZBarrierT6.h" +#include "Utils/Logging/Log.h" #include #include @@ -31,7 +32,7 @@ namespace InfoString infoString; if (!infoString.FromGdtProperties(*gdtEntry)) { - std::cerr << std::format("Failed to read zbarrier gdt entry: \"{}\"\n", assetName); + con::error("Failed to read zbarrier gdt entry: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp index 3952a969..416a8a2a 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/T6.h" #include "Game/T6/ZBarrier/ZBarrierFields.h" +#include "Utils/Logging/Log.h" #include #include @@ -75,7 +76,7 @@ namespace z_barrier infoString, *zbarrier, m_zone.m_script_strings, m_memory, context, registration, zbarrier_fields, std::extent_v); if (!converter.Convert()) { - std::cerr << std::format("Failed to parse zbarrier: \"{}\"\n", assetName); + con::error("Failed to parse zbarrier: \"{}\"", assetName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp index 9b169786..a1e2cd0f 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderZBarrierT6.h" +#include "Utils/Logging/Log.h" #include "ZBarrier/ZBarrierCommon.h" #include @@ -33,7 +34,7 @@ namespace InfoString infoString; if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_ZBARRIER, *file.m_stream)) { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + con::error("Could not parse as info string file: \"{}\"", fileName); return AssetCreationResult::Failure(); } diff --git a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp index 33e6dd60..0445b2e0 100644 --- a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp +++ b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp @@ -1,5 +1,7 @@ #include "InfoStringToStructConverterBase.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -66,7 +68,7 @@ bool InfoStringToStructConverterBase::ConvertInt(const std::string& value, const if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as int\n", value); + con::error("Failed to parse value \"{}\" as int", value); return false; } @@ -80,7 +82,7 @@ bool InfoStringToStructConverterBase::ConvertUint(const std::string& value, cons if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as uint\n", value); + con::error("Failed to parse value \"{}\" as uint", value); return false; } @@ -95,7 +97,7 @@ bool InfoStringToStructConverterBase::ConvertBool(const std::string& value, cons *reinterpret_cast(reinterpret_cast(m_structure) + offset) = intValue != 0; if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as bool\n", value); + con::error("Failed to parse value \"{}\" as bool", value); return false; } @@ -110,7 +112,7 @@ bool InfoStringToStructConverterBase::ConvertQBoolean(const std::string& value, *reinterpret_cast(reinterpret_cast(m_structure) + offset) = intValue != 0 ? 1 : 0; if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as qboolean\n", value); + con::error("Failed to parse value \"{}\" as qboolean", value); return false; } @@ -124,7 +126,7 @@ bool InfoStringToStructConverterBase::ConvertFloat(const std::string& value, con if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as float\n", value); + con::error("Failed to parse value \"{}\" as float", value); return false; } @@ -138,7 +140,7 @@ bool InfoStringToStructConverterBase::ConvertMilliseconds(const std::string& val if (endPtr != &value[value.size()]) { - std::cerr << std::format("Failed to parse value \"{}\" as milliseconds\n", value); + con::error("Failed to parse value \"{}\" as milliseconds", value); return false; } @@ -176,8 +178,7 @@ bool InfoStringToStructConverterBase::ConvertEnumInt( ss << '"' << enumValues[i] << '"'; } - ss << '\n'; - std::cerr << ss.str(); + con::error(ss.str()); return false; } diff --git a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h index af065f0f..e2f936d2 100644 --- a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h +++ b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h @@ -5,6 +5,7 @@ #include "InfoString/InfoString.h" #include "Pool/XAssetInfo.h" #include "Utils/ClassUtils.h" +#include "Utils/Logging/Log.h" #include "Utils/MemoryManager.h" #include "Zone/ZoneScriptStrings.h" @@ -51,7 +52,7 @@ protected: if (c == '\n' && currentEntryOffset != ARRAY_SIZE) { - std::cerr << "Expected value but got new line\n"; + con::error("Expected value but got new line"); return false; } @@ -89,7 +90,7 @@ protected: const auto isLastEntry = currentEntryOffset >= (ARRAY_SIZE - 1); if (isNextEntrySeparator != isLastEntry) { - std::cerr << std::format("Expected {} values but got new line\n", ARRAY_SIZE); + con::error("Expected {} values but got new line", ARRAY_SIZE); return false; } @@ -104,7 +105,7 @@ protected: if (currentEntryOffset > 0) { - std::cerr << std::format("Expected {} values but got new line\n", ARRAY_SIZE); + con::error("Expected {} values but got new line", ARRAY_SIZE); return false; } diff --git a/src/ObjLoading/Localize/Parsing/LocalizeFileReader.cpp b/src/ObjLoading/Localize/Parsing/LocalizeFileReader.cpp index 76a231b6..26aad4d1 100644 --- a/src/ObjLoading/Localize/Parsing/LocalizeFileReader.cpp +++ b/src/ObjLoading/Localize/Parsing/LocalizeFileReader.cpp @@ -3,6 +3,7 @@ #include "LocalizeFileParser.h" #include "Parsing/Impl/CommentRemovingStreamProxy.h" #include "Parsing/Impl/ParserSingleInputStream.h" +#include "Utils/Logging/Log.h" LocalizeFileReader::LocalizeFileReader(std::istream& stream, std::string fileName, GameLanguage language, ILocalizeFileDuplicationChecker& duplicationChecker) : m_file_name(std::move(fileName)), @@ -46,6 +47,6 @@ bool LocalizeFileReader::ReadLocalizeFile(std::vector& entr return true; } - std::cerr << "Parsing localization file failed!\n"; + con::error("Parsing localization file failed!"); return false; } diff --git a/src/ObjLoading/Localize/Parsing/Sequence/SequenceLocalizeFileLanguageValue.cpp b/src/ObjLoading/Localize/Parsing/Sequence/SequenceLocalizeFileLanguageValue.cpp index 60102949..39d7804e 100644 --- a/src/ObjLoading/Localize/Parsing/Sequence/SequenceLocalizeFileLanguageValue.cpp +++ b/src/ObjLoading/Localize/Parsing/Sequence/SequenceLocalizeFileLanguageValue.cpp @@ -1,6 +1,7 @@ #include "SequenceLocalizeFileLanguageValue.h" #include "Parsing/Simple/Matcher/SimpleMatcherFactory.h" +#include "Utils/Logging/Log.h" #include @@ -24,9 +25,9 @@ void SequenceLocalizeFileLanguageValue::ProcessMatch(LocalizeFileParserState* st const auto alreadyDefinedLanguage = state->m_current_reference_languages.find(langName); if (alreadyDefinedLanguage != state->m_current_reference_languages.end()) { - std::ostringstream str; - str << "Value for reference \"" << state->m_current_reference << "\" already defined for language \"" << langToken.IdentifierValue() << "\""; - throw ParsingException(langToken.GetPos(), str.str()); + throw ParsingException( + langToken.GetPos(), + std::format("Value for reference \"{}\" already defined for language \"{}\"", state->m_current_reference, langToken.IdentifierValue())); } state->m_current_reference_languages.emplace(langName); @@ -35,7 +36,7 @@ void SequenceLocalizeFileLanguageValue::ProcessMatch(LocalizeFileParserState* st const auto& currentReference = state->m_current_reference; if (!state->m_duplication_checker.CheckLocalizeEntryForDuplicates(currentReference)) { - std::cout << "Localize: a value for reference \"" << currentReference << "\" was already defined\n"; + con::warn("Localize: a value for reference \"{}\" was already defined", currentReference); } state->m_entries.emplace_back(currentReference, valueToken.StringValue()); diff --git a/src/ObjLoading/Material/JsonMaterialLoader.cpp.template b/src/ObjLoading/Material/JsonMaterialLoader.cpp.template index 3f8bcebc..248d12cc 100644 --- a/src/ObjLoading/Material/JsonMaterialLoader.cpp.template +++ b/src/ObjLoading/Material/JsonMaterialLoader.cpp.template @@ -38,6 +38,7 @@ #include COMMON_HEADER #set JSON_HEADER "\"Game/" + GAME + "/Material/JsonMaterial" + GAME + ".h\"" #include JSON_HEADER +#include "Utils/Logging/Log.h" #include #include @@ -72,7 +73,7 @@ namespace if (type != "material" || version != 1u) { - std::cerr << std::format("Tried to load material \"{}\" but did not find expected type material of version 1\n", material.info.name); + con::error("Tried to load material \"{}\" but did not find expected type material of version 1", material.info.name); return false; } @@ -81,7 +82,7 @@ namespace jRoot.at("_game").get_to(game); if (game != GAME_LOWER) { - std::cerr << std::format("Tried to load material \"{}\" but \"_game\" did not find expected type value {}\n", material.info.name, GAME_LOWER); + con::error("Tried to load material \"{}\" but \"_game\" did not find expected type value {}", material.info.name, GAME_LOWER); return false; } #endif @@ -91,7 +92,7 @@ namespace } catch (const json::exception& e) { - std::cerr << std::format("Failed to parse json of material: {}\n", e.what()); + con::error("Failed to parse json of material: {}", e.what()); } return false; @@ -100,7 +101,7 @@ namespace private: static void PrintError(const Material& material, const std::string& message) { - std::cerr << std::format("Cannot load material \"{}\": {}\n", material.info.name, message); + con::error("Cannot load material \"{}\": {}", material.info.name, message); } #if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5) diff --git a/src/ObjLoading/Menu/AbstractMenuConverter.cpp b/src/ObjLoading/Menu/AbstractMenuConverter.cpp index 86c4c6b6..3b95229e 100644 --- a/src/ObjLoading/Menu/AbstractMenuConverter.cpp +++ b/src/ObjLoading/Menu/AbstractMenuConverter.cpp @@ -1,5 +1,7 @@ #include "AbstractMenuConverter.h" +#include "Utils/Logging/Log.h" + #include #include @@ -15,15 +17,15 @@ AbstractMenuConverter::AbstractMenuConverter(const bool disableOptimizations, IS void AbstractMenuConverter::PrintConversionExceptionDetails(const MenuConversionException& e) { - std::cerr << "ERROR while converting menu:\n"; - std::cerr << std::format(" Menu: {}\n", e.m_menu->m_name); + con::error("ERROR while converting menu:"); + con::error(" Menu: {}", e.m_menu->m_name); if (e.m_item) { - std::cerr << std::format("Item: {}\n", e.m_item->m_name); + con::error("Item: {}", e.m_item->m_name); } - std::cerr << std::format(" Message: {}\n", e.m_message); + con::error(" Message: {}", e.m_message); } const char* AbstractMenuConverter::ConvertString(const std::string& str) const diff --git a/src/ObjLoading/ObjContainer/IPak/IPak.cpp b/src/ObjLoading/ObjContainer/IPak/IPak.cpp index 9308499d..f61fb95a 100644 --- a/src/ObjLoading/ObjContainer/IPak/IPak.cpp +++ b/src/ObjLoading/ObjContainer/IPak/IPak.cpp @@ -2,13 +2,14 @@ #include "IPakStreamManager.h" #include "ObjContainer/IPak/IPakTypes.h" -#include "zlib.h" +#include "Utils/Logging/Log.h" #include #include #include #include #include +#include namespace fs = std::filesystem; @@ -92,7 +93,7 @@ namespace m_stream->read(reinterpret_cast(&indexEntry), sizeof(indexEntry)); if (m_stream->gcount() != sizeof(indexEntry)) { - std::cerr << std::format("Unexpected eof when trying to load index entry {}.\n", itemIndex); + con::error("Unexpected eof when trying to load index entry {}.", itemIndex); return false; } @@ -115,7 +116,7 @@ namespace m_stream->read(reinterpret_cast(§ion), sizeof(section)); if (m_stream->gcount() != sizeof(section)) { - std::cerr << "Unexpected eof when trying to load section.\n"; + con::error("Unexpected eof when trying to load section."); return false; } @@ -143,19 +144,19 @@ namespace m_stream->read(reinterpret_cast(&header), sizeof(header)); if (m_stream->gcount() != sizeof(header)) { - std::cerr << "Unexpected eof when trying to load header.\n"; + con::error("Unexpected eof when trying to load header."); return false; } if (header.magic != ipak_consts::IPAK_MAGIC) { - std::cerr << std::format("Invalid ipak magic '{:#x}'.\n", header.magic); + con::error("Invalid ipak magic '{:#x}'.", header.magic); return false; } if (header.version != ipak_consts::IPAK_VERSION) { - std::cerr << std::format("Unsupported ipak version '{}'.\n", header.version); + con::error("Unsupported ipak version '{}'.", header.version); return false; } @@ -167,13 +168,13 @@ namespace if (m_index_section == nullptr) { - std::cerr << "IPak does not contain an index section.\n"; + con::error("IPak does not contain an index section."); return false; } if (m_data_section == nullptr) { - std::cerr << "IPak does not contain a data section.\n"; + con::error("IPak does not contain a data section."); return false; } diff --git a/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp b/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp index 710b41fb..3174a504 100644 --- a/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp +++ b/src/ObjLoading/ObjContainer/IPak/IPakEntryReadStream.cpp @@ -1,6 +1,7 @@ #include "IPakEntryReadStream.h" #include "ObjContainer/IPak/IPakTypes.h" +#include "Utils/Logging/Log.h" #include #include @@ -128,7 +129,7 @@ bool IPakEntryReadStream::ValidateBlockHeader(const IPakDataBlockHeader* blockHe { if (blockHeader->countAndOffset.count > 31) { - std::cerr << "IPak block has more than 31 commands: " << blockHeader->countAndOffset.count << " -> Invalid\n"; + con::error("IPak block has more than 31 commands: {} -> Invalid", blockHeader->countAndOffset.count); return false; } @@ -142,7 +143,7 @@ bool IPakEntryReadStream::ValidateBlockHeader(const IPakDataBlockHeader* blockHe // The game uses IPAK_COMMAND_SKIP as value for compressed when it intends to skip the specified amount of data if (blockHeader->commands[currentCommand].compressed == 0 || blockHeader->commands[currentCommand].compressed == 1) { - std::cerr << "IPak block offset (" << blockHeader->countAndOffset.offset << ") is not the file head (" << m_file_head << ") -> Invalid\n"; + con::error("IPak block offset ({}) is not the file head ({}) -> Invalid", blockHeader->countAndOffset.offset, m_file_head); return false; } } @@ -167,7 +168,7 @@ bool IPakEntryReadStream::AdjustChunkBufferWindowForBlockHeader(const IPakDataBl { if (requiredChunkCount > IPAK_CHUNK_COUNT_PER_READ) { - std::cerr << "IPak block spans over more than " << IPAK_CHUNK_COUNT_PER_READ << " chunks (" << requiredChunkCount << "), which is not supported.\n"; + con::error("IPak block spans over more than {} chunks ({}), which is not supported.", IPAK_CHUNK_COUNT_PER_READ, requiredChunkCount); return false; } @@ -221,7 +222,7 @@ bool IPakEntryReadStream::ProcessCommand(const size_t commandSize, const int com if (result != LZO_E_OK) { - std::cerr << "Decompressing block with lzo failed: " << result << "!\n"; + con::error("Decompressing block with lzo failed: {}!", result); return false; } diff --git a/src/ObjLoading/ObjContainer/SoundBank/SoundBank.cpp b/src/ObjLoading/ObjContainer/SoundBank/SoundBank.cpp index 06ab0d72..2d8c9847 100644 --- a/src/ObjLoading/ObjContainer/SoundBank/SoundBank.cpp +++ b/src/ObjLoading/ObjContainer/SoundBank/SoundBank.cpp @@ -1,12 +1,13 @@ #include "SoundBank.h" -#include "zlib.h" +#include "Utils/Logging/Log.h" #include #include #include #include #include +#include ObjContainerRepository SoundBank::Repository; @@ -130,50 +131,50 @@ bool SoundBank::ReadHeader() m_stream->read(reinterpret_cast(&m_header), sizeof(m_header)); if (m_stream->gcount() != sizeof(m_header)) { - std::cerr << "Unexpected eof when trying to load sndbank header.\n"; + con::error("Unexpected eof when trying to load sndbank header."); return false; } if (m_header.magic != MAGIC) { - std::cerr << std::format("Invalid sndbank magic 0x{:x}\n", m_header.magic); + con::error("Invalid sndbank magic 0x{:x}", m_header.magic); return false; } if (m_header.version != VERSION) { - std::cerr << std::format("Unsupported sndbank version {} (should be {})\n", m_header.version, VERSION); + con::error("Unsupported sndbank version {} (should be {})", m_header.version, VERSION); return false; } if (m_header.entrySize != sizeof(SoundAssetBankEntry)) { - std::cerr << std::format("Invalid sndbank entry size 0x{:x} (should be 0x{:x})\n", m_header.entrySize, sizeof(SoundAssetBankEntry)); + con::error("Invalid sndbank entry size 0x{:x} (should be 0x{:x})", m_header.entrySize, sizeof(SoundAssetBankEntry)); return false; } if (m_header.fileSize != m_file_size) { - std::cerr << std::format("Invalid sndbank {} (header expects {})\n", m_file_size, m_header.fileSize); + con::error("Invalid sndbank {} (header expects {})", m_file_size, m_header.fileSize); return false; } if (m_header.entryCount && (m_header.entryOffset <= 0 || m_header.entryOffset + sizeof(SoundAssetBankEntry) * m_header.entryCount > static_cast(m_file_size))) { - std::cerr << std::format("Invalid sndbank entry offset {} (filesize is {})\n", m_header.entryOffset, m_file_size); + con::error("Invalid sndbank entry offset {} (filesize is {})", m_header.entryOffset, m_file_size); return false; } if (m_header.checksumOffset <= 0 || m_header.checksumOffset + sizeof(SoundAssetBankChecksum) * m_header.entryCount > static_cast(m_file_size)) { - std::cerr << std::format("Invalid sndbank checksum offset {} (filesize is {})\n", m_header.checksumOffset, m_file_size); + con::error("Invalid sndbank checksum offset {} (filesize is {})", m_header.checksumOffset, m_file_size); return false; } if (m_header.dependencyCount * m_header.dependencySize > sizeof(SoundAssetBankHeader::dependencies)) { - std::cerr << std::format("Invalid sndbank dependency sizes (count is {}; size is {})\n", m_header.dependencyCount, m_header.dependencySize); + con::error("Invalid sndbank dependency sizes (count is {}; size is {})", m_header.dependencyCount, m_header.dependencySize); return false; } @@ -202,13 +203,13 @@ bool SoundBank::ReadEntries() if (m_stream->gcount() != sizeof(entry)) { - std::cerr << std::format("Failed to read sound bank entry at index {}\n", i); + con::error("Failed to read sound bank entry at index {}", i); return false; } if (entry.offset == 0 || entry.offset + entry.size >= m_file_size) { - std::cerr << std::format("Invalid sound bank entry data offset {} (filesize is {})\n", entry.offset, m_header.fileSize); + con::error("Invalid sound bank entry data offset {} (filesize is {})", entry.offset, m_header.fileSize); return false; } @@ -230,7 +231,7 @@ bool SoundBank::ReadChecksums() if (m_stream->gcount() != sizeof(checksum)) { - std::cerr << std::format("Failed to read sound bank checksum at index {}\n", i); + con::error("Failed to read sound bank checksum at index {}", i); return false; } diff --git a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp index fa31a407..67f8547e 100644 --- a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp +++ b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp @@ -5,6 +5,7 @@ #include "Sound/FlacDecoder.h" #include "Sound/WavTypes.h" #include "Utils/FileUtils.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -201,7 +202,7 @@ public: return true; } - std::cerr << std::format("Unable to decode .flac file for sound {}\n", filePath); + con::error("Unable to decode .flac file for sound {}", filePath); return false; } @@ -238,15 +239,14 @@ public: if (!LoadFileByExtension(soundFilePath, sound, soundData, soundSize)) { - std::cerr << std::format("Unable to find a compatible file for sound {}\n", soundFilePath); + con::error("Unable to find a compatible file for sound {}", soundFilePath); return false; } const auto lastEntry = m_entries.rbegin(); if (!sound.m_streamed && lastEntry->frameRateIndex != 6) { - std::cout << std::format("WARNING: Loaded sound \"{}\" should have a framerate of 48000 but doesn't. This sound may not work on all games!\n", - soundFilePath); + con::warn("Loaded sound \"{}\" should have a framerate of 48000 but doesn't. This sound may not work on all games!", soundFilePath); } SoundAssetBankChecksum checksum{}; @@ -297,7 +297,7 @@ public: { if (!WriteEntries()) { - std::cerr << "An error occurred writing the sound bank entries. Please check output.\n"; + con::error("An error occurred writing the sound bank entries. Please check output."); return false; } @@ -311,7 +311,7 @@ public: if (m_current_offset > UINT32_MAX) { - std::cerr << "Sound bank files must be under 4GB. Please reduce the number of sounds being written!\n"; + con::error("Sound bank files must be under 4GB. Please reduce the number of sounds being written!"); return false; } diff --git a/src/ObjLoading/Parsing/Graph2D/Graph2DReader.cpp b/src/ObjLoading/Parsing/Graph2D/Graph2DReader.cpp index f6803f80..487c7e52 100644 --- a/src/ObjLoading/Parsing/Graph2D/Graph2DReader.cpp +++ b/src/ObjLoading/Parsing/Graph2D/Graph2DReader.cpp @@ -5,6 +5,7 @@ #include "Parsing/Simple/Matcher/SimpleMatcherFactory.h" #include "Parsing/Simple/SimpleLexer.h" #include "Parsing/Simple/SimpleParserValue.h" +#include "Utils/Logging/Log.h" #include @@ -210,17 +211,17 @@ namespace graph2d if (!parser.Parse()) { - std::cerr << std::format("Failed to parse {} \"{}\"\n", graphTypeName, graphName); + con::error("Failed to parse {} \"{}\"", graphTypeName, graphName); return nullptr; } if (!parser.HasExpectedKnotCount()) { - std::cerr << std::format("Failed to load {} \"{}\": Actual knot count ({}) differs from expected ({})\n", - graphTypeName, - graphName, - parser.GetActualKnotCount(), - parser.GetExpectedKnotCount()); + con::error("Failed to load {} \"{}\": Actual knot count ({}) differs from expected ({})", + graphTypeName, + graphName, + parser.GetActualKnotCount(), + parser.GetExpectedKnotCount()); return nullptr; } diff --git a/src/ObjLoading/Parsing/Menu/MenuFileReader.cpp b/src/ObjLoading/Parsing/Menu/MenuFileReader.cpp index d475a806..6790807d 100644 --- a/src/ObjLoading/Parsing/Menu/MenuFileReader.cpp +++ b/src/ObjLoading/Parsing/Menu/MenuFileReader.cpp @@ -8,6 +8,7 @@ #include "Parsing/Impl/ParserMultiInputStream.h" #include "Parsing/Impl/ParserSingleInputStream.h" #include "Parsing/Simple/SimpleLexer.h" +#include "Utils/Logging/Log.h" using namespace menu; @@ -65,25 +66,25 @@ bool MenuFileReader::IsValidEndState(const MenuFileParserState* state) const { if (state->m_current_item) { - std::cerr << "In \"" << m_file_name << "\": Unclosed item at end of file!\n"; + con::error("In \"{}\": Unclosed item at end of file!", m_file_name); return false; } if (state->m_current_menu) { - std::cerr << "In \"" << m_file_name << "\": Unclosed menu at end of file!\n"; + con::error("In \"{}\": Unclosed menu at end of file!", m_file_name); return false; } if (state->m_current_function) { - std::cerr << "In \"" << m_file_name << "\": Unclosed function at end of file!\n"; + con::error("In \"{}\": Unclosed function at end of file!", m_file_name); return false; } if (state->m_in_global_scope) { - std::cerr << "In \"" << m_file_name << "\": Did not close global scope!\n"; + con::error("In \"{}\": Did not close global scope!", m_file_name); return false; } @@ -125,11 +126,11 @@ std::unique_ptr MenuFileReader::ReadMenuFile() if (!parser->Parse()) { - std::cerr << "Parsing menu file failed!\n"; + con::error("Parsing menu file failed!"); const auto* parserEndState = parser->GetState(); if (parserEndState->m_current_event_handler_set && !parserEndState->m_permissive_mode) - std::cerr << "You can use the --menu-permissive option to try to compile the event handler script anyway.\n"; + con::error("You can use the --menu-permissive option to try to compile the event handler script anyway."); return nullptr; } diff --git a/src/ObjLoading/SearchPath/IWD.cpp b/src/ObjLoading/SearchPath/IWD.cpp index d84a8246..99e77807 100644 --- a/src/ObjLoading/SearchPath/IWD.cpp +++ b/src/ObjLoading/SearchPath/IWD.cpp @@ -2,6 +2,7 @@ #include "ObjLoading.h" #include "Utils/FileToZlibWrapper.h" +#include "Utils/Logging/Log.h" #include #include @@ -215,7 +216,7 @@ namespace if (m_unz_file == nullptr) { - std::cerr << std::format("Could not open IWD \"{}\"\n", m_path); + con::error("Could not open IWD \"{}\"", m_path); return false; } @@ -239,7 +240,7 @@ namespace ret = unzGoToNextFile(m_unz_file); } - std::cout << std::format("Loaded IWD \"{}\" with {} entries\n", m_path, m_entry_map.size()); + con::info("Loaded IWD \"{}\" with {} entries", m_path, m_entry_map.size()); return true; } @@ -261,7 +262,7 @@ namespace assert(!m_has_open_file); if (m_has_open_file) { - std::cerr << "Trying to open new IWD file while last one was not yet closed.\n"; + con::error("Trying to open new IWD file while last one was not yet closed."); return SearchPathOpenFile(); } diff --git a/src/ObjLoading/StateMap/StateMapHandler.cpp b/src/ObjLoading/StateMap/StateMapHandler.cpp index 07f2a364..1025fee4 100644 --- a/src/ObjLoading/StateMap/StateMapHandler.cpp +++ b/src/ObjLoading/StateMap/StateMapHandler.cpp @@ -1,5 +1,7 @@ #include "StateMapHandler.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -76,7 +78,7 @@ StateMapVars StateMapHandler::BuildVars(const uint32_t* baseStateBits) const if (matchingValue != var.m_values.end()) result.AddValue(var.m_name, matchingValue->m_name); else - std::cerr << "Could not find base value for state map var \"" << var.m_name << "\"\n"; + con::error("Could not find base value for state map var \"{}\"", var.m_name); } return result; diff --git a/src/ObjLoading/StateMap/StateMapReader.cpp b/src/ObjLoading/StateMap/StateMapReader.cpp index f025cff1..a55b98fa 100644 --- a/src/ObjLoading/StateMap/StateMapReader.cpp +++ b/src/ObjLoading/StateMap/StateMapReader.cpp @@ -4,6 +4,7 @@ #include "Parsing/Impl/ParserSingleInputStream.h" #include "Parsing/Matcher/StateMapExpressionMatchers.h" #include "Parsing/StateMapParser.h" +#include "Utils/Logging/Log.h" #include @@ -22,13 +23,13 @@ bool StateMapReader::IsValidEndState(const StateMapParserState* state) const { if (state->m_current_rule) { - std::cerr << "In \"" << m_file_name << "\": Unclosed rule at end of file!\n"; + con::error("In \"{}\": Unclosed rule at end of file!", m_file_name); return false; } if (state->m_in_entry) { - std::cerr << "In \"" << m_file_name << "\": Unclosed entry at end of file!\n"; + con::error("In \"{}\": Unclosed entry at end of file!", m_file_name); return false; } @@ -36,7 +37,7 @@ bool StateMapReader::IsValidEndState(const StateMapParserState* state) const { if (state->m_definition->m_state_map_entries[i].m_rules.empty()) { - std::cerr << "In \"" << m_file_name << "\": State map must define a rule for \"" << state->m_layout.m_entry_layout.m_entries[i].m_name << "\"!\n"; + con::error("In \"{}\": State map must define a rule for \"{}\"!", m_file_name, state->m_layout.m_entry_layout.m_entries[i].m_name); return false; } } @@ -59,7 +60,7 @@ std::unique_ptr StateMapReader::ReadStateMapDefinition() con const auto success = parser->Parse(); if (!success) { - std::cout << "Parsing state map file \"" << m_file_name << "\" failed!\n"; + con::error("Parsing state map file \"{}\" failed!", m_file_name); return {}; } diff --git a/src/ObjLoading/StructuredDataDef/StructuredDataDefReader.cpp b/src/ObjLoading/StructuredDataDef/StructuredDataDefReader.cpp index c5c9f62c..9ff1d5f4 100644 --- a/src/ObjLoading/StructuredDataDef/StructuredDataDefReader.cpp +++ b/src/ObjLoading/StructuredDataDef/StructuredDataDefReader.cpp @@ -6,6 +6,7 @@ #include "Parsing/Impl/ParserMultiInputStream.h" #include "Parsing/Impl/ParserSingleInputStream.h" #include "StructuredDataDef/Parsing/StructuredDataDefParser.h" +#include "Utils/Logging/Log.h" #include #include @@ -54,7 +55,7 @@ std::vector> StructuredDataDefReader::R if (success) return parser->GetDefs(); - std::cerr << std::format("Parsing structured data def file \"{}\" failed!\n", m_file_name); + con::error("Parsing structured data def file \"{}\" failed!", m_file_name); return {}; } diff --git a/src/ObjLoading/Techset/TechniqueFileReader.cpp b/src/ObjLoading/Techset/TechniqueFileReader.cpp index 60f2c5b8..71a40fbf 100644 --- a/src/ObjLoading/Techset/TechniqueFileReader.cpp +++ b/src/ObjLoading/Techset/TechniqueFileReader.cpp @@ -4,6 +4,7 @@ #include "Parsing/Impl/ParserSingleInputStream.h" #include "Parsing/Simple/SimpleLexer.h" #include "Parsing/TechniqueFileParser.h" +#include "Utils/Logging/Log.h" #include @@ -33,6 +34,6 @@ bool TechniqueFileReader::ReadTechniqueDefinition() const if (success) return true; - std::cout << "Parsing technique file \"" << m_file_name << "\" failed!\n"; + con::error("Parsing technique file \"{}\" failed!", m_file_name); return false; } diff --git a/src/ObjLoading/Techset/TechsetFileReader.cpp b/src/ObjLoading/Techset/TechsetFileReader.cpp index 6a704b0a..8b7c61e5 100644 --- a/src/ObjLoading/Techset/TechsetFileReader.cpp +++ b/src/ObjLoading/Techset/TechsetFileReader.cpp @@ -3,6 +3,7 @@ #include "Parsing/Impl/CommentRemovingStreamProxy.h" #include "Parsing/Impl/ParserSingleInputStream.h" #include "Parsing/TechsetFileParser.h" +#include "Utils/Logging/Log.h" #include #include @@ -34,6 +35,6 @@ std::unique_ptr TechsetFileReader::ReadTechsetDefini if (success) return parser->GetTechsetDefinition(); - std::cerr << std::format("Parsing techset file \"{}\" failed!\n", m_file_name); + con::error("Parsing techset file \"{}\" failed!", m_file_name); return nullptr; } diff --git a/src/ObjLoading/Weapon/AccuracyGraphLoader.cpp b/src/ObjLoading/Weapon/AccuracyGraphLoader.cpp index 75c22889..9c05316f 100644 --- a/src/ObjLoading/Weapon/AccuracyGraphLoader.cpp +++ b/src/ObjLoading/Weapon/AccuracyGraphLoader.cpp @@ -1,6 +1,7 @@ #include "AccuracyGraphLoader.h" #include "Parsing/Graph2D/Graph2DReader.h" +#include "Utils/Logging/Log.h" #include #include @@ -13,7 +14,7 @@ namespace const auto file = searchPath.Open(fileName); if (!file.IsOpen()) { - std::cerr << std::format("Failed to open file for accuracy graph: {}/{}\n", subFolder, graphName); + con::error("Failed to open file for accuracy graph: {}/{}", subFolder, graphName); return nullptr; } diff --git a/src/ObjLoading/XModel/Gltf/GltfBinInput.cpp b/src/ObjLoading/XModel/Gltf/GltfBinInput.cpp index b954adca..2433d75d 100644 --- a/src/ObjLoading/XModel/Gltf/GltfBinInput.cpp +++ b/src/ObjLoading/XModel/Gltf/GltfBinInput.cpp @@ -1,5 +1,6 @@ #include "GltfBinInput.h" +#include "Utils/Logging/Log.h" #include "XModel/Gltf/GltfConstants.h" #include @@ -41,7 +42,7 @@ bool BinInput::ReadGltfData(std::istream& stream) if (magic != GLTF_MAGIC) { - std::cerr << "Invalid magic when trying to read GLB\n"; + con::error("Invalid magic when trying to read GLB"); return false; } @@ -51,7 +52,7 @@ bool BinInput::ReadGltfData(std::istream& stream) if (version != GLTF_VERSION) { - std::cerr << std::format("Unsupported version {} when trying to read GLB: Expected version {}\n", version, GLTF_VERSION); + con::error("Unsupported version {} when trying to read GLB: Expected version {}", version, GLTF_VERSION); return false; } @@ -82,7 +83,7 @@ bool BinInput::ReadGltfData(std::istream& stream) } catch (const nlohmann::json::exception& e) { - std::cerr << std::format("Failed trying to parse JSON of GLB: {}\n", e.what()); + con::error("Failed trying to parse JSON of GLB: {}", e.what()); return false; } } @@ -103,7 +104,7 @@ bool BinInput::ReadGltfData(std::istream& stream) if (!m_json) { - std::cerr << "Failed to load GLB due to missing JSON\n"; + con::error("Failed to load GLB due to missing JSON"); return false; } @@ -116,7 +117,7 @@ bool BinInput::Read(std::istream& stream, void* dest, const size_t dataSize, con if (stream.gcount() != dataSize) { if (errorWhenFailed) - std::cerr << std::format("Unexpected EOF while reading GLB {}\n", readTypeName); + con::error("Unexpected EOF while reading GLB {}", readTypeName); return false; } diff --git a/src/ObjLoading/XModel/Gltf/GltfLoader.cpp b/src/ObjLoading/XModel/Gltf/GltfLoader.cpp index add6b39f..0adba623 100644 --- a/src/ObjLoading/XModel/Gltf/GltfLoader.cpp +++ b/src/ObjLoading/XModel/Gltf/GltfLoader.cpp @@ -3,6 +3,7 @@ #include "Internal/GltfAccessor.h" #include "Internal/GltfBuffer.h" #include "Internal/GltfBufferView.h" +#include "Utils/Logging/Log.h" #pragma warning(push, 0) #include @@ -798,7 +799,7 @@ namespace } catch (const nlohmann::json::exception& e) { - std::cerr << std::format("Failed to parse GLTF JSON: {}\n", e.what()); + con::error("Failed to parse GLTF JSON: {}", e.what()); return nullptr; } @@ -818,7 +819,7 @@ namespace } catch (const GltfLoadException& e) { - std::cerr << std::format("Failed to load GLTF: {}\n", e.Str()); + con::error("Failed to load GLTF: {}", e.Str()); return nullptr; } } diff --git a/src/ObjLoading/XModel/Gltf/GltfTextInput.cpp b/src/ObjLoading/XModel/Gltf/GltfTextInput.cpp index ff885002..7250c0a1 100644 --- a/src/ObjLoading/XModel/Gltf/GltfTextInput.cpp +++ b/src/ObjLoading/XModel/Gltf/GltfTextInput.cpp @@ -1,5 +1,7 @@ #include "GltfTextInput.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -41,7 +43,7 @@ bool TextInput::ReadGltfData(std::istream& stream) } catch (nlohmann::json::exception& e) { - std::cerr << std::format("Failed to parse json of GLTF: {}", e.what()); + con::error("Failed to parse json of GLTF: {}", e.what()); } return false; diff --git a/src/ObjLoading/XModel/LoaderXModel.cpp.template b/src/ObjLoading/XModel/LoaderXModel.cpp.template index fce40ef4..0c6b4067 100644 --- a/src/ObjLoading/XModel/LoaderXModel.cpp.template +++ b/src/ObjLoading/XModel/LoaderXModel.cpp.template @@ -26,6 +26,7 @@ #include JSON_HEADER #include "Asset/AssetRegistration.h" +#include "Utils/Logging/Log.h" #include "Utils/QuatInt16.h" #include "Utils/StringUtils.h" #include "XModel/Gltf/GltfBinInput.h" @@ -79,7 +80,7 @@ namespace AssetRegistration registration(assetName, xmodel); if (!LoadFromFile(*file.m_stream, *xmodel, context, registration)) { - std::cerr << std::format("Failed to load xmodel \"{}\"\n", assetName); + con::error("Failed to load xmodel \"{}\"", assetName); return AssetCreationResult::Failure(); } @@ -100,14 +101,14 @@ namespace if (type != "xmodel" || version < 1u || version > 2u) { - std::cerr << std::format("Tried to load xmodel \"{}\" but did not find expected type material of version 1 or 2\n", xmodel.name); + con::error("Tried to load xmodel \"{}\" but did not find expected type material of version 1 or 2", xmodel.name); return false; } if (version == 1u) { m_gltf_bad_rotation_formulas = true; - std::cerr << std::format("DEPRECATED: XModel {} is version 1 that made use of bad GLTF bone rotations.\n", xmodel.name); + con::warn("DEPRECATED: XModel {} is version 1 that made use of bad GLTF bone rotations.", xmodel.name); } else { @@ -119,7 +120,7 @@ namespace } catch (const nlohmann::json::exception& e) { - std::cerr << std::format("Failed to parse json of xmodel: {}\n", e.what()); + con::error("Failed to parse json of xmodel: {}", e.what()); } return false; @@ -127,7 +128,7 @@ namespace static void PrintError(const XModel& xmodel, const std::string& message) { - std::cerr << std::format("Cannot load xmodel \"{}\": {}\n", xmodel.name, message); + con::error("Cannot load xmodel \"{}\": {}", xmodel.name, message); } std::unique_ptr LoadModelByExtension(std::istream& stream, const std::string& extension) const @@ -694,7 +695,7 @@ namespace constexpr auto maxTriCount = std::numeric_limits::max(); if (commonObject.m_faces.size() > maxTriCount) { - std::cerr << std::format("Surface cannot have more than {} faces\n", maxTriCount); + con::error("Surface cannot have more than {} faces", maxTriCount); return false; } @@ -727,7 +728,7 @@ namespace constexpr auto maxVertices = std::numeric_limits::max(); if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVertices) { - std::cerr << std::format("Lod exceeds limit of {} vertices\n", maxVertices); + con::error("Lod exceeds limit of {} vertices", maxVertices); return false; } @@ -764,7 +765,7 @@ namespace } else { - std::cerr << std::format("Models must not have vertices that are influenced by more than {} bones\n", + con::error("Models must not have vertices that are influenced by more than {} bones", std::extent_v + 1); return false; } diff --git a/src/ObjLoading/XModel/PartClassificationState.cpp b/src/ObjLoading/XModel/PartClassificationState.cpp index be898f50..688d3f29 100644 --- a/src/ObjLoading/XModel/PartClassificationState.cpp +++ b/src/ObjLoading/XModel/PartClassificationState.cpp @@ -2,6 +2,7 @@ #include "Csv/CsvStream.h" #include "ObjLoading.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -17,13 +18,12 @@ bool PartClassificationState::Load(const char** hitLocNames, const size_t hitLoc if (m_loaded) return true; - if (ObjLoading::Configuration.Verbose) - std::cout << "Loading part classification...\n"; + con::debug("Loading part classification..."); const auto file = searchPath.Open(PART_CLASSIFICATION_FILE); if (!file.IsOpen()) { - std::cerr << std::format("Could not load part classification: Failed to open {}\n", PART_CLASSIFICATION_FILE); + con::error("Could not load part classification: Failed to open {}", PART_CLASSIFICATION_FILE); return false; } @@ -58,7 +58,7 @@ bool PartClassificationState::LoadRow(const char** hitLocStart, const char** hit if (row.size() != 2) { - std::cerr << "Could not load part classification: Invalid row\n"; + con::error("Could not load part classification: Invalid row"); return false; } @@ -68,7 +68,7 @@ bool PartClassificationState::LoadRow(const char** hitLocStart, const char** hit const auto foundHitLoc = std::find(hitLocStart, hitLocEnd, row[1]); if (foundHitLoc == hitLocEnd) { - std::cerr << std::format("Invalid hitloc name in row {}: {}\n", rowIndex + 1, row[1]); + con::error("Invalid hitloc name in row {}: {}", rowIndex + 1, row[1]); return false; } diff --git a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp index 245e5790..fbc44a99 100644 --- a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp @@ -9,6 +9,7 @@ #include "Image/Texture.h" #include "ObjWriting.h" #include "SearchPath/ISearchPath.h" +#include "Utils/Logging/Log.h" #include #include @@ -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; } diff --git a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp index 9cb481db..777c419b 100644 --- a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp @@ -2,6 +2,7 @@ #include "Dumping/Localize/StringFileDumper.h" #include "Localize/LocalizeCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -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 diff --git a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp index ccf79977..923d3d57 100644 --- a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp @@ -2,6 +2,7 @@ #include "Sound/WavTypes.h" #include "Sound/WavWriter.h" +#include "Utils/Logging/Log.h" #include @@ -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; } } diff --git a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp index 57fd3cf3..248c4098 100644 --- a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp @@ -6,6 +6,7 @@ #include "Image/IwiLoader.h" #include "Image/IwiWriter8.h" #include "ObjWriting.h" +#include "Utils/Logging/Log.h" #include #include @@ -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; } diff --git a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp index 77b4b44e..bff7b2ee 100644 --- a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp @@ -2,6 +2,7 @@ #include "Dumping/Localize/StringFileDumper.h" #include "Localize/LocalizeCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -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 diff --git a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp index a61c012a..f706ed0e 100644 --- a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp @@ -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 @@ -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)); - 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; } diff --git a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp index 9698e608..a1e9a045 100644 --- a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp @@ -1,5 +1,7 @@ #include "RawFileDumperIW4.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -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; } diff --git a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp index 8a2c6360..20e34703 100644 --- a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp @@ -2,6 +2,7 @@ #include "Sound/WavTypes.h" #include "Sound/WavWriter.h" +#include "Utils/Logging/Log.h" #include @@ -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; } } diff --git a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp index 24ae8652..f8eb6e90 100644 --- a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp @@ -5,9 +5,11 @@ #include "Pool/GlobalAssetPool.h" #include "Shader/D3D9ShaderAnalyser.h" #include "Techset/TechsetCommon.h" +#include "Utils/Logging/Log.h" #include #include +#include #include #include #include @@ -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(); diff --git a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp index e25b8227..038f94ea 100644 --- a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp @@ -6,6 +6,7 @@ #include "Image/IwiLoader.h" #include "Image/IwiWriter8.h" #include "ObjWriting.h" +#include "Utils/Logging/Log.h" #include #include @@ -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; } diff --git a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp index c8b7b0d0..a9f979ee 100644 --- a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp @@ -2,6 +2,7 @@ #include "Dumping/Localize/StringFileDumper.h" #include "Localize/LocalizeCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -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 diff --git a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp index 71ca717b..9021e3b3 100644 --- a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp @@ -1,5 +1,7 @@ #include "RawFileDumperIW5.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -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; } diff --git a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp index 8deec609..4a50e20b 100644 --- a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp @@ -2,6 +2,7 @@ #include "Sound/WavTypes.h" #include "Sound/WavWriter.h" +#include "Utils/Logging/Log.h" #include @@ -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; } } diff --git a/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp index d8992797..6843efa8 100644 --- a/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp @@ -6,6 +6,7 @@ #include "Image/IwiLoader.h" #include "Image/IwiWriter13.h" #include "ObjWriting.h" +#include "Utils/Logging/Log.h" #include #include @@ -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; } diff --git a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp index 60f3ca58..0ed7388b 100644 --- a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp @@ -2,6 +2,7 @@ #include "Dumping/Localize/StringFileDumper.h" #include "Localize/LocalizeCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -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 diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp index 2043098c..a3d41751 100644 --- a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp @@ -1,5 +1,6 @@ #include "RawFileDumperT5.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -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(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; } diff --git a/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp index bb3255b2..02317695 100644 --- a/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp @@ -7,6 +7,7 @@ #include "Image/IwiWriter27.h" #include "ObjContainer/IPak/IPak.h" #include "ObjWriting.h" +#include "Utils/Logging/Log.h" #include #include @@ -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; } diff --git a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp index 550b92d6..c6281264 100644 --- a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp @@ -2,6 +2,7 @@ #include "Dumping/Localize/StringFileDumper.h" #include "Localize/LocalizeCommon.h" +#include "Utils/Logging/Log.h" #include #include @@ -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 diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp index a7f29926..9388c216 100644 --- a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp @@ -1,5 +1,7 @@ #include "RawFileDumperT6.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -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; } diff --git a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp index efa5e52d..aca65ad7 100644 --- a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp @@ -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 @@ -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(format), alias.assetFileName); + con::error("Cannot dump sound (Unknown sound format {}): \"{}\"", static_cast(format), alias.assetFileName); break; default: assert(false); - std::cerr << std::format("Cannot dump sound (Unknown sound format {}): \"{}\"\n", static_cast(format), alias.assetFileName); + con::error("Cannot dump sound (Unknown sound format {}): \"{}\"", static_cast(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; } diff --git a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp index 02e7899e..57649091 100644 --- a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp @@ -2,6 +2,7 @@ #include "Csv/CsvStream.h" #include "ObjContainer/SoundBank/SoundBank.h" +#include "Utils/Logging/Log.h" #include @@ -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; } diff --git a/src/ObjWriting/Material/AbstractMaterialConstantZoneState.cpp b/src/ObjWriting/Material/AbstractMaterialConstantZoneState.cpp index bdbee0c2..3a87d05a 100644 --- a/src/ObjWriting/Material/AbstractMaterialConstantZoneState.cpp +++ b/src/ObjWriting/Material/AbstractMaterialConstantZoneState.cpp @@ -3,6 +3,7 @@ #include "ObjWriting.h" #include "Shader/D3D11ShaderAnalyser.h" #include "Shader/D3D9ShaderAnalyser.h" +#include "Utils/Logging/Log.h" #include @@ -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(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()); } } diff --git a/src/ObjWriting/Weapon/AccuracyGraphWriter.cpp b/src/ObjWriting/Weapon/AccuracyGraphWriter.cpp index 4da6e353..29f70050 100644 --- a/src/ObjWriting/Weapon/AccuracyGraphWriter.cpp +++ b/src/ObjWriting/Weapon/AccuracyGraphWriter.cpp @@ -1,5 +1,7 @@ #include "AccuracyGraphWriter.h" +#include "Utils/Logging/Log.h" + #include 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; } diff --git a/src/Parser/Parsing/Impl/AbstractParser.h b/src/Parser/Parsing/Impl/AbstractParser.h index a1e28095..b76f2053 100644 --- a/src/Parser/Parsing/Impl/AbstractParser.h +++ b/src/Parser/Parsing/Impl/AbstractParser.h @@ -4,6 +4,7 @@ #include "Parsing/IParser.h" #include "Parsing/ParsingException.h" #include "Parsing/Sequence/AbstractSequence.h" +#include "Utils/Logging/Log.h" #include #include @@ -63,12 +64,12 @@ public: if (!line.IsEof()) { - std::cerr << "Error: " << pos.m_filename.get() << " L" << pos.m_line << ':' << pos.m_column << " Could not parse expression:\n" - << line.m_line.substr(pos.m_column - 1) << "\n"; + con::error( + "{} L{}:{} Could not parse expression:\n{}", pos.m_filename.get(), pos.m_line, pos.m_column, line.m_line.substr(pos.m_column - 1)); } else { - std::cerr << "Error: " << pos.m_filename.get() << " L" << pos.m_line << ':' << pos.m_column << " Could not parse expression.\n"; + con::error("{} L{}:{} Could not parse expression.", pos.m_filename.get(), pos.m_line, pos.m_column); } return false; } @@ -81,11 +82,11 @@ public: if (!line.IsEof() && line.m_line.size() > static_cast(pos.m_column - 1)) { - std::cerr << "Error: " << e.FullMessage() << "\n" << line.m_line.substr(pos.m_column - 1) << "\n"; + con::error("{}\n{}", e.FullMessage(), line.m_line.substr(pos.m_column - 1)); } else { - std::cerr << "Error: " << e.FullMessage() << "\n"; + con::error(e.FullMessage()); } return false; diff --git a/src/RawTemplater/RawTemplater.cpp b/src/RawTemplater/RawTemplater.cpp index 902e199b..57465926 100644 --- a/src/RawTemplater/RawTemplater.cpp +++ b/src/RawTemplater/RawTemplater.cpp @@ -2,6 +2,7 @@ #include "RawTemplaterArguments.h" #include "Templating/Templater.h" +#include "Utils/Logging/Log.h" #include #include @@ -21,7 +22,7 @@ class RawTemplater::Impl std::ifstream file(filename, std::ios::in | std::ios::binary); if (!file.is_open()) { - std::cerr << "Failed to open file \"" << filename << "\"\n"; + con::error("Failed to open file \"{}\"", filename); return false; } @@ -61,7 +62,7 @@ public: m_build_log_file = std::ofstream(m_args.m_build_log_file, std::ios::out | std::ios::binary); if (!m_build_log_file.is_open()) { - std::cerr << "Failed to open build log file \"" << m_args.m_build_log_file << "\"\n"; + con::error("Failed to open build log file \"{}\"", m_args.m_build_log_file); return false; } m_write_build_log = true; diff --git a/src/RawTemplater/RawTemplaterArguments.cpp b/src/RawTemplater/RawTemplaterArguments.cpp index 7962e164..5b2eaf56 100644 --- a/src/RawTemplater/RawTemplaterArguments.cpp +++ b/src/RawTemplater/RawTemplaterArguments.cpp @@ -3,6 +3,7 @@ #include "GitVersion.h" #include "Utils/Arguments/CommandLineOption.h" #include "Utils/Arguments/UsageInformation.h" +#include "Utils/Logging/Log.h" #include #include @@ -83,7 +84,7 @@ void RawTemplaterArguments::PrintUsage() const void RawTemplaterArguments::PrintVersion() { - std::cout << std::format("OpenAssetTools RawTemplater {}\n", GIT_VERSION); + con::info("OpenAssetTools RawTemplater {}", GIT_VERSION); } bool RawTemplaterArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue) diff --git a/src/RawTemplater/Templating/Templater.cpp b/src/RawTemplater/Templating/Templater.cpp index 4ca68e30..40c2203f 100644 --- a/src/RawTemplater/Templating/Templater.cpp +++ b/src/RawTemplater/Templating/Templater.cpp @@ -8,6 +8,7 @@ #include "SetDefineStreamProxy.h" #include "TemplatingStreamProxy.h" #include "Utils/ClassUtils.h" +#include "Utils/Logging/Log.h" #include #include @@ -219,7 +220,7 @@ namespace templating { if (!m_active_variations.empty()) { - std::cerr << "Template with variations must specify a filename\n"; + con::error("Template with variations must specify a filename"); return false; } @@ -231,7 +232,7 @@ namespace templating m_output_stream << cachedData; } - std::cout << "Templated file \"" << m_output_file << "\"\n"; + con::info("Templated file \"{}\"", m_output_file); if (buildLogFile) *buildLogFile << "Templated file \"" << m_output_file << "\"\n"; @@ -276,7 +277,7 @@ namespace templating const auto isValidRedefinition = existingVariation->second->GetVariationType() == TemplatingVariationType::SWITCH; if (!isValidRedefinition) - std::cerr << "Redefinition of \"" << switchName << "\" as switch is invalid\n"; + con::error("Redefinition of \"{}\" as switch is invalid", switchName); return isValidRedefinition; } @@ -299,7 +300,7 @@ namespace templating const auto isValidRedefinition = existingVariation->second->GetVariationType() == TemplatingVariationType::OPTIONS; if (!isValidRedefinition) - std::cerr << "Redefinition of \"" << optionsName << "\" as options is invalid\n"; + con::error("Redefinition of \"{}\" as options is invalid", optionsName); return isValidRedefinition; } @@ -337,7 +338,7 @@ namespace templating { if (m_write_output_to_file) { - std::cerr << "Cannot skip when already writing to file\n"; + con::error("Cannot skip when already writing to file"); return false; } @@ -355,7 +356,7 @@ namespace templating m_output_stream = std::ofstream(m_output_file, std::ios::out | std::ios::binary); if (!m_output_stream.is_open()) { - std::cerr << "Failed to open output file \"" << m_output_file << "\"\n"; + con::error("Failed to open output file \"{}\"", m_output_file); return false; } @@ -412,7 +413,7 @@ bool Templater::TemplateToDirectory(const std::string& outputDirectory) const } catch (ParsingException& e) { - std::cerr << "Error: " << e.FullMessage() << "\n"; + con::error(e.FullMessage()); return false; } diff --git a/src/Unlinker/ContentLister/ContentPrinter.cpp b/src/Unlinker/ContentLister/ContentPrinter.cpp index 4a5ef024..2134dcdc 100644 --- a/src/Unlinker/ContentLister/ContentPrinter.cpp +++ b/src/Unlinker/ContentLister/ContentPrinter.cpp @@ -1,5 +1,7 @@ #include "ContentPrinter.h" +#include "Utils/Logging/Log.h" + #include #include @@ -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(""); } diff --git a/src/Unlinker/Unlinker.cpp b/src/Unlinker/Unlinker.cpp index 32d751bc..977c1ad3 100644 --- a/src/Unlinker/Unlinker.cpp +++ b/src/Unlinker/Unlinker.cpp @@ -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; diff --git a/src/Unlinker/UnlinkerArgs.cpp b/src/Unlinker/UnlinkerArgs.cpp index 08746e50..4b6b8087 100644 --- a/src/Unlinker/UnlinkerArgs.cpp +++ b/src/Unlinker/UnlinkerArgs.cpp @@ -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 @@ -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; } diff --git a/src/Unlinker/UnlinkerPaths.cpp b/src/Unlinker/UnlinkerPaths.cpp index 91d235a7..59aec518 100644 --- a/src/Unlinker/UnlinkerPaths.cpp +++ b/src/Unlinker/UnlinkerPaths.cpp @@ -2,6 +2,7 @@ #include "SearchPath/IWD.h" #include "SearchPath/SearchPathFilesystem.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -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; } diff --git a/src/Utils/Utils/Arguments/ArgumentParser.cpp b/src/Utils/Utils/Arguments/ArgumentParser.cpp index 8192f778..14fc2e32 100644 --- a/src/Utils/Utils/Arguments/ArgumentParser.cpp +++ b/src/Utils/Utils/Arguments/ArgumentParser.cpp @@ -1,5 +1,6 @@ #include "ArgumentParser.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include @@ -81,7 +82,7 @@ bool ArgumentParser::ParseArguments(std::vector& 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& 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& args) const auto parameterCount = static_cast(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& args) if (param.compare(0, std::char_traits::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; } diff --git a/src/Utils/Utils/Arguments/UsageInformation.cpp b/src/Utils/Utils/Arguments/UsageInformation.cpp index 28d9097e..e3f393a5 100644 --- a/src/Utils/Utils/Arguments/UsageInformation.cpp +++ b/src/Utils/Utils/Arguments/UsageInformation.cpp @@ -1,5 +1,7 @@ #include "UsageInformation.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -105,7 +107,7 @@ void UsageInformation::Print() } } - std::cout << str.str() << "\n"; + con::info(str.str()); } void UsageInformation::PrintUsageOverview(std::stringstream& str) diff --git a/src/Utils/Utils/Logging/Log.h b/src/Utils/Utils/Logging/Log.h index 1e72af34..2cd2f746 100644 --- a/src/Utils/Utils/Logging/Log.h +++ b/src/Utils/Utils/Logging/Log.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace con { @@ -20,29 +21,55 @@ namespace con void _warn_internal(const std::string& str); void _error_internal(const std::string& str); - template void debug(std::format_string fmt, Args&&... args) + inline void debug(const std::string& str) { if (static_cast(globalLogLevel) > static_cast(LogLevel::DEBUG)) return; - _debug_internal(std::vformat(fmt.get(), std::make_format_args(args...))); + _debug_internal(str); } - template void info(std::format_string fmt, Args&&... args) + template void debug(std::format_string fmt, Arg0&& arg0, OtherArgs&&... otherArgs) + { + if (static_cast(globalLogLevel) > static_cast(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(globalLogLevel) > static_cast(LogLevel::INFO)) return; - _info_internal(std::vformat(fmt.get(), std::make_format_args(args...))); + _info_internal(str); } - template void warn(std::format_string fmt, Args&&... args) + template void info(std::format_string fmt, Arg0&& arg0, OtherArgs&&... otherArgs) + { + if (static_cast(globalLogLevel) > static_cast(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(globalLogLevel) > static_cast(LogLevel::WARN)) return; - _warn_internal(std::vformat(fmt.get(), std::make_format_args(args...))); + _warn_internal(str); } - template void error(std::format_string fmt, Args&&... args) + template void warn(std::format_string fmt, Arg0&& arg0, OtherArgs&&... otherArgs) { - _error_internal(std::vformat(fmt.get(), std::make_format_args(args...))); + if (static_cast(globalLogLevel) > static_cast(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 void error(std::format_string fmt, Arg0&& arg0, OtherArgs&&... otherArgs) + { + _error_internal(std::vformat(fmt.get(), std::make_format_args(arg0, otherArgs...))); } } // namespace con diff --git a/src/ZoneCodeGeneratorLib/Generating/CodeGenerator.cpp b/src/ZoneCodeGeneratorLib/Generating/CodeGenerator.cpp index 2b1d9bc6..38064100 100644 --- a/src/ZoneCodeGeneratorLib/Generating/CodeGenerator.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/CodeGenerator.cpp @@ -5,6 +5,7 @@ #include "Templates/ZoneLoadTemplate.h" #include "Templates/ZoneMarkTemplate.h" #include "Templates/ZoneWriteTemplate.h" +#include "Utils/Logging/Log.h" #include #include @@ -42,7 +43,7 @@ bool CodeGenerator::GenerateCodeForTemplate(const RenderingContext& context, ICo if (!stream.is_open()) { - std::cerr << std::format("Failed to open file '{}'\n", p.string()); + con::error("Failed to open file '{}'", p.string()); return false; } @@ -59,7 +60,7 @@ bool CodeGenerator::GetAssetWithName(IDataRepository* repository, const std::str auto* def = repository->GetDataDefinitionByName(name); if (def == nullptr) { - std::cerr << std::format("Could not find type with name '{}'\n", name); + con::error("Could not find type with name '{}'", name); return false; } @@ -67,13 +68,13 @@ bool CodeGenerator::GetAssetWithName(IDataRepository* repository, const std::str asset = defWithMembers != nullptr ? repository->GetInformationFor(defWithMembers) : nullptr; if (asset == nullptr) { - std::cerr << std::format("Could not find type with name '{}'\n", name); + con::error("Could not find type with name '{}'", name); return false; } if (!StructureComputations(asset).IsAsset()) { - std::cerr << std::format("Type is not an asset '{}'\n", name); + con::error("Type is not an asset '{}'", name); return false; } @@ -101,7 +102,7 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository) const auto foundTemplate = m_template_mapping.find(templateName); if (foundTemplate == m_template_mapping.end()) { - std::cerr << std::format("Unknown template '{}'.\n", generationTask.m_template_name); + con::error("Unknown template '{}'.", generationTask.m_template_name); return false; } @@ -112,13 +113,11 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository) auto context = RenderingContext::BuildContext(repository, asset); if (!GenerateCodeForTemplate(*context, foundTemplate->second.get())) { - std::cerr << std::format( - "Failed to generate code for asset '{}' with preset '{}'\n", asset->m_definition->GetFullName(), foundTemplate->first); + con::error("Failed to generate code for asset '{}' with preset '{}'", asset->m_definition->GetFullName(), foundTemplate->first); return false; } - std::cout << std::format( - "Successfully generated code for asset '{}' with preset '{}'\n", asset->m_definition->GetFullName(), foundTemplate->first); + con::info("Successfully generated code for asset '{}' with preset '{}'", asset->m_definition->GetFullName(), foundTemplate->first); } } else @@ -133,8 +132,7 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository) } } const auto end = std::chrono::steady_clock::now(); - if (m_args->m_verbose) - std::cout << std::format("Generating code took {}ms\n", std::chrono::duration_cast(end - start).count()); + con::debug("Generating code took {}ms", std::chrono::duration_cast(end - start).count()); return true; } diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/CommandsFileReader.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/CommandsFileReader.cpp index 449ead72..a92a8614 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/CommandsFileReader.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/CommandsFileReader.cpp @@ -13,6 +13,7 @@ #include "Parsing/PostProcessing/MemberLeafsPostProcessor.h" #include "Parsing/PostProcessing/UnionsPostProcessor.h" #include "Parsing/PostProcessing/UsagesPostProcessor.h" +#include "Utils/Logging/Log.h" #include #include @@ -37,7 +38,7 @@ bool CommandsFileReader::OpenBaseStream() auto stream = std::make_unique(m_filename); if (!stream->IsOpen()) { - std::cerr << "Could not open commands file\n"; + con::error("Could not open commands file"); return false; } @@ -74,10 +75,7 @@ void CommandsFileReader::SetupPostProcessors() bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository) { - if (m_args->m_verbose) - { - std::cout << std::format("Reading commands file: {}\n", m_filename); - } + con::debug("Reading commands file: {}", m_filename); if (!OpenBaseStream()) return false; @@ -91,8 +89,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository) const auto result = parser->Parse(); const auto end = std::chrono::steady_clock::now(); - if (m_args->m_verbose) - std::cout << std::format("Processing commands took {}ms\n", std::chrono::duration_cast(end - start).count()); + con::debug("Processing commands took {}ms", std::chrono::duration_cast(end - start).count()); if (!result) return false; diff --git a/src/ZoneCodeGeneratorLib/Parsing/Header/HeaderFileReader.cpp b/src/ZoneCodeGeneratorLib/Parsing/Header/HeaderFileReader.cpp index 64ba8d46..6f548feb 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Header/HeaderFileReader.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Header/HeaderFileReader.cpp @@ -10,6 +10,7 @@ #include "Parsing/PostProcessing/CreateMemberInformationPostProcessor.h" #include "Parsing/PostProcessing/CreateStructureInformationPostProcessor.h" #include "Parsing/PostProcessing/IPostProcessor.h" +#include "Utils/Logging/Log.h" #include #include @@ -36,7 +37,7 @@ bool HeaderFileReader::OpenBaseStream() auto stream = std::make_unique(m_filename); if (!stream->IsOpen()) { - std::cerr << "Could not open header file\n"; + con::error("Could not open header file"); return false; } @@ -71,8 +72,7 @@ void HeaderFileReader::SetupPostProcessors() bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository) { - if (m_args->m_verbose) - std::cout << std::format("Reading header file: {}\n", m_filename); + con::debug("Reading header file: {}", m_filename); if (!OpenBaseStream()) return false; @@ -88,8 +88,7 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository) result = parser->SaveToRepository(repository); const auto end = std::chrono::steady_clock::now(); - if (m_args->m_verbose) - std::cout << std::format("Processing header took {}ms\n", std::chrono::duration_cast(end - start).count()); + con::debug("Processing header took {}ms", std::chrono::duration_cast(end - start).count()); if (!result) return false; diff --git a/src/ZoneCodeGeneratorLib/Parsing/Header/Impl/HeaderParserState.cpp b/src/ZoneCodeGeneratorLib/Parsing/Header/Impl/HeaderParserState.cpp index e26d68ad..40bc1b87 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Header/Impl/HeaderParserState.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Header/Impl/HeaderParserState.cpp @@ -2,6 +2,7 @@ #include "Domain/Definition/EnumDefinition.h" #include "Parsing/Header/Block/HeaderBlockNone.h" +#include "Utils/Logging/Log.h" #include #include @@ -97,7 +98,7 @@ bool HeaderParserState::ResolveForwardDeclarations() if (dataDefinition == nullptr) { - std::cerr << std::format("Forward declaration \"{}\" was not defined\n", forwardDeclaration->GetFullName()); + con::error("Forward declaration \"{}\" was not defined", forwardDeclaration->GetFullName()); return false; } diff --git a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp index e6b9fdc3..65032723 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp @@ -2,6 +2,7 @@ #include "Domain/Definition/ArrayDeclarationModifier.h" #include "Utils/Alignment.h" +#include "Utils/Logging/Log.h" #include #include @@ -189,7 +190,7 @@ namespace return true; if (structDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATING) { - std::cerr << "Detected circular dependency:\n"; + con::error("Detected circular dependency:"); return false; } @@ -212,7 +213,7 @@ namespace return true; if (unionDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATING) { - std::cerr << "Detected circular dependency:\n"; + con::error("Detected circular dependency:"); return false; } @@ -257,35 +258,28 @@ bool CalculateSizeAndAlignPostProcessor::PostProcess(IDataRepository* repository { if (repository->GetArchitecture() == Architecture::UNKNOWN) { - std::cerr << "You must set an architecture!\n"; + con::error("You must set an architecture!"); return false; } for (auto* structDefinition : repository->GetAllStructs()) { if (!CalculateFields(repository, structDefinition)) - { - std::cout << "\n"; + return false; - } } for (auto* unionDefinition : repository->GetAllUnions()) { if (!CalculateFields(repository, unionDefinition)) - { - std::cout << "\n"; + return false; - } } for (auto* typedefDeclaration : repository->GetAllTypedefs()) { if (!CalculateFields(repository, typedefDeclaration->m_type_declaration.get())) - { - std::cout << "\n"; return false; - } } return true; diff --git a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/UnionsPostProcessor.cpp b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/UnionsPostProcessor.cpp index 83283aae..bcd8d0e9 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/UnionsPostProcessor.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/UnionsPostProcessor.cpp @@ -1,5 +1,7 @@ #include "UnionsPostProcessor.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -24,7 +26,7 @@ namespace if (entriesWithoutConditionCount > 1 && !info->m_usages.empty() && !info->m_is_leaf) { - std::cerr << std::format("Union '{}' has more than one entry without a condition!\n", info->m_definition->GetFullName()); + con::error("Union '{}' has more than one entry without a condition!", info->m_definition->GetFullName()); return false; } diff --git a/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp b/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp index 306c58c1..81a8161e 100644 --- a/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp +++ b/src/ZoneCodeGeneratorLib/ZoneCodeGeneratorArguments.cpp @@ -3,6 +3,7 @@ #include "GitVersion.h" #include "Utils/Arguments/CommandLineOption.h" #include "Utils/Arguments/UsageInformation.h" +#include "Utils/Logging/Log.h" #include #include @@ -136,7 +137,7 @@ void ZoneCodeGeneratorArguments::PrintUsage() const void ZoneCodeGeneratorArguments::PrintVersion() { - std::cout << std::format("OpenAssetTools ZoneCodeGenerator {}\n", GIT_VERSION); + con::info("OpenAssetTools ZoneCodeGenerator {}", GIT_VERSION); } bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bool& shouldContinue) @@ -185,7 +186,7 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo } else { - std::cout << "At least one header file must be specified via -h / --header.\n"; + con::error("At least one header file must be specified via -h / --header."); return false; } @@ -197,7 +198,7 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo } else { - std::cout << "At least one commands file must be specified via -c / --commands-file.\n"; + con::error("At least one commands file must be specified via -c / --commands-file."); return false; } @@ -219,7 +220,7 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo if (m_task_flags == 0) { - std::cout << "There was no output task specified.\n"; + con::warn("There was no output task specified."); PrintUsage(); return false; } diff --git a/src/ZoneCommon/Zone/AssetList/AssetListReader.cpp b/src/ZoneCommon/Zone/AssetList/AssetListReader.cpp index fbc616bc..84ee2270 100644 --- a/src/ZoneCommon/Zone/AssetList/AssetListReader.cpp +++ b/src/ZoneCommon/Zone/AssetList/AssetListReader.cpp @@ -2,6 +2,7 @@ #include "Csv/CsvStream.h" #include "Game/IGame.h" +#include "Utils/Logging/Log.h" #include "Zone/AssetNameResolver.h" #include @@ -35,7 +36,7 @@ namespace const auto maybeType = m_asset_name_resolver->GetAssetTypeByName(typeName); if (!maybeType) { - std::cerr << std::format("Unknown asset type name \"{}\"\n", typeName); + con::error("Unknown asset type name \"{}\"", typeName); if (failure) *failure = true; return false; @@ -90,7 +91,7 @@ std::optional AssetListReader::ReadAssetList(const std::string& zoneN return assetList; } else if (logMissing) - std::cerr << std::format("Failed to open file for assetlist: {}\n", assetListFileName); + con::error("Failed to open file for assetlist: {}", assetListFileName); return std::nullopt; } diff --git a/src/ZoneCommon/Zone/Definition/Parsing/Sequence/SequenceZoneDefinitionMetaData.cpp b/src/ZoneCommon/Zone/Definition/Parsing/Sequence/SequenceZoneDefinitionMetaData.cpp index 68e8d3c1..61752842 100644 --- a/src/ZoneCommon/Zone/Definition/Parsing/Sequence/SequenceZoneDefinitionMetaData.cpp +++ b/src/ZoneCommon/Zone/Definition/Parsing/Sequence/SequenceZoneDefinitionMetaData.cpp @@ -1,5 +1,6 @@ #include "SequenceZoneDefinitionMetaData.h" +#include "Utils/Logging/Log.h" #include "Utils/StringUtils.h" #include "Zone/Definition/Parsing/Matcher/ZoneDefinitionMatcherFactory.h" @@ -112,11 +113,11 @@ namespace } const auto keyPos = keyToken.GetPos(); - std::cerr << std::format("Warning: {} L{}: Zone definition \">type,{}\" is deprecated and should be removed. {}\n", - keyPos.m_filename.get(), - keyPos.m_line, - keyToken.FieldValue(), - deprecationSuggestedAction); + con::error("Warning: {} L{}: Zone definition \">type,{}\" is deprecated and should be removed. {}", + keyPos.m_filename.get(), + keyPos.m_line, + keyToken.FieldValue(), + deprecationSuggestedAction); } } // namespace diff --git a/src/ZoneCommon/Zone/Definition/ZoneDefinitionStream.cpp b/src/ZoneCommon/Zone/Definition/ZoneDefinitionStream.cpp index 4b54c7cc..d8df6641 100644 --- a/src/ZoneCommon/Zone/Definition/ZoneDefinitionStream.cpp +++ b/src/ZoneCommon/Zone/Definition/ZoneDefinitionStream.cpp @@ -4,6 +4,7 @@ #include "Parsing/Impl/DefinesStreamProxy.h" #include "Parsing/Impl/IncludingStreamProxy.h" #include "Parsing/Impl/ParserSingleInputStream.h" +#include "Utils/Logging/Log.h" #include "Zone/Definition/Parsing/ZoneDefinitionLexer.h" #include "Zone/Definition/Parsing/ZoneDefinitionParser.h" @@ -44,7 +45,7 @@ void ZoneDefinitionInputStream::SetPreviouslySetGame(GameId game) std::unique_ptr ZoneDefinitionInputStream::ReadDefinition() { - std::cout << std::format("Reading zone definition file: {}\n", m_file_name); + con::info("Reading zone definition file: {}", m_file_name); const auto lexer = std::make_unique(m_stream); const auto parser = std::make_unique(lexer.get(), m_target_name, m_search_path, *m_stream, m_previously_set_game); @@ -55,7 +56,7 @@ std::unique_ptr ZoneDefinitionInputStream::ReadDefinition() definition = parser->GetParsedValue(); const auto end = std::chrono::steady_clock::now(); - std::cout << std::format("Processing zone definition took {}ms\n", std::chrono::duration_cast(end - start).count()); + con::info("Processing zone definition took {}ms", std::chrono::duration_cast(end - start).count()); return std::move(definition); } diff --git a/src/ZoneCommon/Zone/XChunk/XChunkProcessorInflate.cpp b/src/ZoneCommon/Zone/XChunk/XChunkProcessorInflate.cpp index a9fdec9d..9d1058ce 100644 --- a/src/ZoneCommon/Zone/XChunk/XChunkProcessorInflate.cpp +++ b/src/ZoneCommon/Zone/XChunk/XChunkProcessorInflate.cpp @@ -1,5 +1,6 @@ #include "XChunkProcessorInflate.h" +#include "Utils/Logging/Log.h" #include "XChunkException.h" #include @@ -26,7 +27,7 @@ size_t XChunkProcessorInflate::Process(unsigned streamNumber, const uint8_t* inp ret = inflate(&stream, Z_FULL_FLUSH); if (ret != Z_STREAM_END) { - std::cerr << std::format("inflate of stream failed with error code {}: {}\n", streamNumber, ret, stream.msg); + con::error("inflate of stream failed with error code {}: {}", streamNumber, ret, stream.msg); throw XChunkException(std::format("Zone has invalid or unsupported compression: {}", stream.msg)); } diff --git a/src/ZoneCommon/Zone/XChunk/XChunkProcessorLzxDecompress.cpp b/src/ZoneCommon/Zone/XChunk/XChunkProcessorLzxDecompress.cpp index 657f9143..6778150e 100644 --- a/src/ZoneCommon/Zone/XChunk/XChunkProcessorLzxDecompress.cpp +++ b/src/ZoneCommon/Zone/XChunk/XChunkProcessorLzxDecompress.cpp @@ -1,5 +1,7 @@ #include "XChunkProcessorLzxDecompress.h" +#include "Utils/Logging/Log.h" + #include #include #include @@ -22,7 +24,7 @@ namespace void LogErrorHeaderSpace(size_t remainingInputSize) { - std::cerr << std::format("XMemCompress: Not enough data for header: {}\n", remainingInputSize); + con::error("XMemCompress: Not enough data for header: {}", remainingInputSize); } } // namespace @@ -99,19 +101,19 @@ size_t XChunkProcessorLzxDecompress::Process( if (srcSize == 0 || dstSize == 0) { // Other implementations do not handle this as a failure, game code suggests otherwise though - std::cerr << std::format("XMemCompress: EOF: {} {}, {}\n", srcSize, dstSize, curInputSize); + con::error("XMemCompress: EOF: {} {}, {}", srcSize, dstSize, curInputSize); return curOutputOffset; } if (static_cast(srcSize) + suffixSize > curInputSize) { - std::cerr << std::format("XMemCompress: block size bigger than remaining data: {} > {}\n", srcSize, curInputSize); + con::error("XMemCompress: block size bigger than remaining data: {} > {}", srcSize, curInputSize); return curOutputOffset; } if (dstSize > curOutputSize) { - std::cerr << std::format("XMemCompress: output size bigger than remaining data: {} > {}\n", dstSize, curOutputSize); + con::error("XMemCompress: output size bigger than remaining data: {} > {}", dstSize, curOutputSize); return curOutputOffset; } @@ -123,7 +125,7 @@ size_t XChunkProcessorLzxDecompress::Process( if (ret != DECR_OK) { - std::cerr << std::format("XMemCompress: lzx decompression failed: {}\n", ret); + con::error("XMemCompress: lzx decompression failed: {}", ret); return curOutputOffset; } } diff --git a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp index 20adf9db..1bfd60d6 100644 --- a/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ZoneLoaderFactoryIW4.cpp @@ -23,6 +23,7 @@ #include "Loading/Steps/StepVerifyMagic.h" #include "Loading/Steps/StepVerifySignature.h" #include "Utils/ClassUtils.h" +#include "Utils/Logging/Log.h" #include #include @@ -100,7 +101,7 @@ namespace if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD))) { - std::cerr << "Invalid public key for signature checking\n"; + con::error("Invalid public key for signature checking"); return nullptr; } diff --git a/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp b/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp index 647a2c68..b7e97184 100644 --- a/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp +++ b/src/ZoneLoading/Game/IW5/ZoneLoaderFactoryIW5.cpp @@ -22,6 +22,7 @@ #include "Loading/Steps/StepVerifyMagic.h" #include "Loading/Steps/StepVerifySignature.h" #include "Utils/ClassUtils.h" +#include "Utils/Logging/Log.h" #include #include @@ -84,7 +85,7 @@ namespace if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD, sizeof(ZoneConstants::RSA_PUBLIC_KEY_INFINITY_WARD))) { - std::cerr << "Invalid public key for signature checking\n"; + con::error("Invalid public key for signature checking"); return nullptr; } diff --git a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp index e0eaf669..813d8602 100644 --- a/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp +++ b/src/ZoneLoading/Game/T6/ZoneLoaderFactoryT6.cpp @@ -18,6 +18,7 @@ #include "Loading/Steps/StepVerifyMagic.h" #include "Loading/Steps/StepVerifySignature.h" #include "Utils/Endianness.h" +#include "Utils/Logging/Log.h" #include "Zone/XChunk/XChunkProcessorInflate.h" #include "Zone/XChunk/XChunkProcessorLzxDecompress.h" #include "Zone/XChunk/XChunkProcessorSalsa20Decryption.h" @@ -136,7 +137,7 @@ namespace if (!rsa->SetKey(ZoneConstants::RSA_PUBLIC_KEY_TREYARCH, sizeof(ZoneConstants::RSA_PUBLIC_KEY_TREYARCH))) { - std::cerr << "Invalid public key for signature checking\n"; + con::error("Invalid public key for signature checking"); return nullptr; } @@ -269,7 +270,7 @@ std::unique_ptr ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader& fs::path dumpFileNamePath = fs::path(fileName).filename(); dumpFileNamePath.replace_extension(".dat"); std::string dumpFileName = dumpFileNamePath.string(); - std::cerr << std::format("Dumping xbox assets is not supported, making a full fastfile data dump to {}\n", dumpFileName); + con::warn("Dumping xbox assets is not supported, making a full fastfile data dump to {}", dumpFileName); zoneLoader->AddLoadingStep(step::CreateStepDumpData(dumpFileName, 0xFFFFFFFF)); } diff --git a/src/ZoneLoading/Loading/ZoneLoader.cpp b/src/ZoneLoading/Loading/ZoneLoader.cpp index a1f7d0c0..a97f6c6f 100644 --- a/src/ZoneLoading/Loading/ZoneLoader.cpp +++ b/src/ZoneLoading/Loading/ZoneLoader.cpp @@ -2,6 +2,7 @@ #include "Exception/LoadingException.h" #include "LoadingFileStream.h" +#include "Utils/Logging/Log.h" #include #include @@ -87,7 +88,7 @@ std::unique_ptr ZoneLoader::LoadZone(std::istream& stream) } catch (LoadingException& e) { - std::cerr << std::format("Loading fastfile failed: {}\n", e.DetailedMessage()); + con::error("Loading fastfile failed: {}", e.DetailedMessage()); return nullptr; } diff --git a/src/ZoneLoading/Zone/Stream/ZoneInputStream.cpp b/src/ZoneLoading/Zone/Stream/ZoneInputStream.cpp index 5e843841..296060fc 100644 --- a/src/ZoneLoading/Zone/Stream/ZoneInputStream.cpp +++ b/src/ZoneLoading/Zone/Stream/ZoneInputStream.cpp @@ -5,6 +5,7 @@ #include "Loading/Exception/InvalidOffsetBlockOffsetException.h" #include "Loading/Exception/OutOfBlockBoundsException.h" #include "Utils/Alignment.h" +#include "Utils/Logging/Log.h" #include #include @@ -414,8 +415,7 @@ namespace ss << " " << m_block_offsets[block->m_index]; } - ss << "\n"; - std::cout << ss.str(); + con::debug(ss.str()); } #endif diff --git a/src/ZoneLoading/ZoneLoading.cpp b/src/ZoneLoading/ZoneLoading.cpp index ad934839..3d15b80c 100644 --- a/src/ZoneLoading/ZoneLoading.cpp +++ b/src/ZoneLoading/ZoneLoading.cpp @@ -2,6 +2,7 @@ #include "Loading/IZoneLoaderFactory.h" #include "Loading/ZoneLoader.h" +#include "Utils/Logging/Log.h" #include "Utils/ObjFileStream.h" #include @@ -18,7 +19,7 @@ std::unique_ptr ZoneLoading::LoadZone(const std::string& path) if (!file.is_open()) { - std::cerr << std::format("Could not open file '{}'.\n", path); + con::error("Could not open file '{}'.", path); return nullptr; } @@ -26,7 +27,7 @@ std::unique_ptr ZoneLoading::LoadZone(const std::string& path) file.read(reinterpret_cast(&header), sizeof(header)); if (file.gcount() != sizeof(header)) { - std::cerr << std::format("Failed to read zone header from file '{}'.\n", path); + con::error("Failed to read zone header from file '{}'.", path); return nullptr; } @@ -42,7 +43,7 @@ std::unique_ptr ZoneLoading::LoadZone(const std::string& path) if (!zoneLoader) { - std::cerr << std::format("Could not create factory for zone '{}'.\n", zoneName); + con::error("Could not create factory for zone '{}'.", zoneName); return nullptr; } diff --git a/src/ZoneWriting/Writing/ZoneWriter.cpp b/src/ZoneWriting/Writing/ZoneWriter.cpp index 82e4287b..1f7a0ca1 100644 --- a/src/ZoneWriting/Writing/ZoneWriter.cpp +++ b/src/ZoneWriting/Writing/ZoneWriter.cpp @@ -1,5 +1,6 @@ #include "ZoneWriter.h" +#include "Utils/Logging/Log.h" #include "WritingException.h" #include "WritingFileStream.h" @@ -73,12 +74,12 @@ bool ZoneWriter::WriteZone(std::ostream& stream) } catch (WritingException& e) { - std::cout << std::format("Writing fastfile failed: {}\n", e.Message()); + con::error("Writing fastfile failed: {}", e.Message()); return false; } catch (std::runtime_error& e) { - std::cout << std::format("Writing fastfile failed: {}\n", e.what()); + con::error("Writing fastfile failed: {}", e.what()); return false; } diff --git a/src/ZoneWriting/ZoneWriting.cpp b/src/ZoneWriting/ZoneWriting.cpp index ad32e70f..d0ee4da7 100644 --- a/src/ZoneWriting/ZoneWriting.cpp +++ b/src/ZoneWriting/ZoneWriting.cpp @@ -1,5 +1,6 @@ #include "ZoneWriting.h" +#include "Utils/Logging/Log.h" #include "Writing/IZoneWriterFactory.h" #include @@ -15,7 +16,7 @@ bool ZoneWriting::WriteZone(std::ostream& stream, const Zone& zone) const auto zoneWriter = factory->CreateWriter(zone); if (zoneWriter == nullptr) { - std::cerr << std::format("Could not create ZoneWriter for zone \"{}\".\n", zone.m_name); + con::error("Could not create ZoneWriter for zone \"{}\".", zone.m_name); return false; } @@ -23,7 +24,7 @@ bool ZoneWriting::WriteZone(std::ostream& stream, const Zone& zone) const auto end = std::chrono::high_resolution_clock::now(); - std::cout << std::format("Writing zone \"{}\" took {} ms.\n", zone.m_name, std::chrono::duration_cast(end - start).count()); + con::info("Writing zone \"{}\" took {} ms.", zone.m_name, std::chrono::duration_cast(end - start).count()); return result; }