eliminat molt de ruido de la consola de log

This commit is contained in:
2026-04-14 13:04:24 +02:00
parent f5da35bfb2
commit cf7ea6cc9c
27 changed files with 144 additions and 383 deletions

View File

@@ -12,7 +12,6 @@
#include <stdexcept> // Para runtime_error
#include "resource_helper.hpp" // Para loadFile
#include "ui/logger.hpp" // Para info, section, CYAN
#include "utils.hpp" // Para getFileName
// Singleton
@@ -37,9 +36,7 @@ void Asset::addToMap(const std::string& file_path, Type type, bool required, boo
// Verificar si ya existe el archivo
if (file_list_.contains(filename)) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Warning: Asset '%s' already exists, overwriting",
filename.c_str());
std::cout << "Warning: Asset '" << filename << "' already exists, overwriting" << '\n';
}
file_list_.emplace(filename, Item{std::move(full_path), type, required});
@@ -54,9 +51,7 @@ void Asset::add(const std::string& file_path, Type type, bool required, bool abs
void Asset::loadFromFile(const std::string& config_file_path, const std::string& prefix, const std::string& system_folder) {
std::ifstream file(config_file_path);
if (!file.is_open()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error: Cannot open config file: %s",
config_file_path.c_str());
std::cout << "Error: Cannot open config file: " << config_file_path << '\n';
return;
}
@@ -89,9 +84,7 @@ void Asset::loadFromFile(const std::string& config_file_path, const std::string&
// Verificar que tenemos al menos tipo y ruta
if (parts.size() < 2) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Warning: Malformed line %d in config file (insufficient fields)",
line_number);
std::cout << "Warning: Malformed line " << line_number << " in config file (insufficient fields)" << '\n';
continue;
}
@@ -118,14 +111,10 @@ void Asset::loadFromFile(const std::string& config_file_path, const std::string&
addToMap(path, type, required, absolute);
} catch (const std::exception& e) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error parsing line %d in config file: %s",
line_number,
e.what());
std::cout << "Error parsing line " << line_number << " in config file: " << e.what() << '\n';
}
}
std::cout << "Loaded " << file_list_.size() << " assets from config file" << '\n';
file.close();
}
@@ -136,7 +125,7 @@ auto Asset::getPath(const std::string& filename) const -> std::string {
return it->second.file;
}
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: file %s not found", filename.c_str());
std::cout << "Warning: file " << filename << " not found" << '\n';
return "";
}
@@ -147,7 +136,7 @@ auto Asset::loadData(const std::string& filename) const -> std::vector<uint8_t>
return ResourceHelper::loadFile(it->second.file);
}
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: file %s not found for data loading", filename.c_str());
std::cout << "Warning: file " << filename << " not found for data loading" << '\n';
return {};
}
@@ -160,9 +149,6 @@ auto Asset::exists(const std::string& filename) const -> bool {
auto Asset::check() const -> bool {
bool success = true;
// SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES");
Logger::section("CHECKING FILES", Logger::CYAN);
// Agrupar por tipo para mostrar organizado
std::unordered_map<Type, std::vector<const Item*>> by_type;
@@ -177,19 +163,11 @@ auto Asset::check() const -> bool {
Type asset_type = static_cast<Type>(type);
if (by_type.contains(asset_type)) {
Logger::info(getTypeName(asset_type) + " FILES");
bool type_success = true;
for (const auto* item : by_type[asset_type]) {
if (!checkFile(item->file)) {
success = false;
type_success = false;
}
}
if (type_success) {
Logger::info("All files are OK.\n");
}
}
}
return success;
@@ -215,9 +193,7 @@ auto Asset::checkFile(const std::string& path) const -> bool {
file.close();
if (!success) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error: Could not open file: %s",
path.c_str());
std::cout << "Error: Could not open file: " << path << '\n';
}
return success;