2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-17 18:52:06 +00:00

chore: update all logging to use centralized logging component

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

View File

@@ -5,6 +5,7 @@
#include "Templates/ZoneLoadTemplate.h"
#include "Templates/ZoneMarkTemplate.h"
#include "Templates/ZoneWriteTemplate.h"
#include "Utils/Logging/Log.h"
#include <filesystem>
#include <format>
@@ -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<std::chrono::milliseconds>(end - start).count());
con::debug("Generating code took {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
return true;
}

View File

@@ -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 <algorithm>
#include <chrono>
@@ -37,7 +38,7 @@ bool CommandsFileReader::OpenBaseStream()
auto stream = std::make_unique<ParserFilesystemStream>(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<std::chrono::milliseconds>(end - start).count());
con::debug("Processing commands took {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
if (!result)
return false;

View File

@@ -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 <algorithm>
#include <chrono>
@@ -36,7 +37,7 @@ bool HeaderFileReader::OpenBaseStream()
auto stream = std::make_unique<ParserFilesystemStream>(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<std::chrono::milliseconds>(end - start).count());
con::debug("Processing header took {}ms", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
if (!result)
return false;

View File

@@ -2,6 +2,7 @@
#include "Domain/Definition/EnumDefinition.h"
#include "Parsing/Header/Block/HeaderBlockNone.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -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;
}

View File

@@ -2,6 +2,7 @@
#include "Domain/Definition/ArrayDeclarationModifier.h"
#include "Utils/Alignment.h"
#include "Utils/Logging/Log.h"
#include <cassert>
#include <cstdint>
@@ -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;

View File

@@ -1,5 +1,7 @@
#include "UnionsPostProcessor.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
#include <format>
#include <iostream>
@@ -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;
}

View File

@@ -3,6 +3,7 @@
#include "GitVersion.h"
#include "Utils/Arguments/CommandLineOption.h"
#include "Utils/Arguments/UsageInformation.h"
#include "Utils/Logging/Log.h"
#include <format>
#include <iostream>
@@ -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;
}