refactor(log): migra els subsistemes restants i elimina iostream
Acaba la migració dels std::cout/cerr a Log::*:
- core/locale, core/ui/ui_config, core/rendering/{screen,text,gif,
surface, sprite/animated_sprite, sdl3gpu/*}.
- game/{options, debug_config, editor/editor_config, levels/level_manager,
map/{map,tilemap,paint_layer}, entities/entity_manager_loadlevel}.
Severitats coherents: warns per a configs absents amb fallback,
errors per a YAML malformat o E/S fallida, infos per a estats.
Resultat:
- 0 occurrences de std::cout/std::cerr a source/.
- Cap #include <iostream> orfà (eliminat de surface.cpp).
- Output funcional idèntic al històric; AEE_LOG filtra (ex.
`AEE_LOG=warn` només mostra warnings, `AEE_LOG=*:warn,Tag:info`
combina globals i overrides).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5fce52e0ad
commit
c8882a3f6e
17 files changed
+83
-101
No files matched your search
+11
-12
@@ -3,7 +3,6 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -12,6 +11,7 @@
|
||||
#include "core/input/gamepad_manager.hpp"
|
||||
#include "external/fkyaml_node.hpp"
|
||||
#include "utils/defines.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace {
|
||||
std::ofstream dst(path + ".bak", std::ios::binary);
|
||||
if (!dst) { return; }
|
||||
dst << src.rdbuf();
|
||||
std::cout << "Options: còpia de seguretat a " << path << ".bak\n";
|
||||
Log::info("Options", "còpia de seguretat a {}.bak", path);
|
||||
}
|
||||
|
||||
void parseWindow(const fkyaml::node& yaml) {
|
||||
@@ -463,7 +463,7 @@ namespace {
|
||||
try {
|
||||
auto yaml = fkyaml::node::deserialize(CONTENT);
|
||||
if (!yaml.contains("presets") || !yaml["presets"].is_sequence()) {
|
||||
std::cout << "Options: " << kind_label << " manca `presets:`; reescrivint amb defaults.\n";
|
||||
Log::warn("Options", "{} manca `presets:`; reescrivint amb defaults.", kind_label);
|
||||
backupFile(path);
|
||||
presets = defaults_fn();
|
||||
return save_fn();
|
||||
@@ -475,15 +475,15 @@ namespace {
|
||||
presets.push_back(preset);
|
||||
}
|
||||
if (presets.empty()) {
|
||||
std::cout << "Options: " << kind_label << " sense presets; reescrivint amb defaults.\n";
|
||||
Log::warn("Options", "{} sense presets; reescrivint amb defaults.", kind_label);
|
||||
backupFile(path);
|
||||
presets = defaults_fn();
|
||||
return save_fn();
|
||||
}
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
std::cout << "Options: error parsejant " << kind_label << ": " << e.what() << '\n';
|
||||
std::cout << "Options: reescrivint el fitxer amb presets per defecte.\n";
|
||||
Log::error("Options", "error parsejant {}: {}", kind_label, e.what());
|
||||
Log::info("Options", "reescrivint el fitxer amb presets per defecte.");
|
||||
backupFile(path);
|
||||
presets = defaults_fn();
|
||||
return save_fn();
|
||||
@@ -655,8 +655,7 @@ namespace Options {
|
||||
// amb els defaults de la versió nova. El fitxer original queda
|
||||
// a `<path>.bak` per si l'usuari volia preservar tuning manual.
|
||||
if (file_version != Texts::VERSION) {
|
||||
std::cout << "Options: config.yaml versió \"" << file_version
|
||||
<< "\" != \"" << Texts::VERSION << "\"; reescrivint amb defaults.\n";
|
||||
Log::warn("Options", "config.yaml versió \"{}\" != \"{}\"; reescrivint amb defaults.", file_version, Texts::VERSION);
|
||||
backupFile(g_config_file_path);
|
||||
return saveToFile();
|
||||
}
|
||||
@@ -679,8 +678,8 @@ namespace Options {
|
||||
if (CHANGED) { saveToFile(); }
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
std::cout << "Options: error parsejant config.yaml: " << e.what() << '\n';
|
||||
std::cout << "Options: reescrivint el fitxer amb defaults.\n";
|
||||
Log::error("Options", "error parsejant config.yaml: {}", e.what());
|
||||
Log::info("Options", "reescrivint el fitxer amb defaults.");
|
||||
backupFile(g_config_file_path);
|
||||
return saveToFile();
|
||||
}
|
||||
@@ -843,7 +842,7 @@ namespace Options {
|
||||
const auto IT = std::ranges::find_if(g_crtpi_presets,
|
||||
[](const CrtPiPreset& preset) { return preset.name == g_video.shader.current_crtpi_preset; });
|
||||
if (IT == g_crtpi_presets.end()) {
|
||||
std::cout << "Options: preset CrtPi \"" << g_video.shader.current_crtpi_preset << "\" no trobat; aplicant defaults.\n";
|
||||
Log::warn("Options", "preset CrtPi \"{}\" no trobat; aplicant defaults.", g_video.shader.current_crtpi_preset);
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
@@ -871,7 +870,7 @@ namespace Options {
|
||||
const auto IT = std::ranges::find_if(g_postfx_presets,
|
||||
[](const PostFXPreset& preset) { return preset.name == g_video.shader.current_postfx_preset; });
|
||||
if (IT == g_postfx_presets.end()) {
|
||||
std::cout << "Options: preset PostFX \"" << g_video.shader.current_postfx_preset << "\" no trobat; aplicant passthrough.\n";
|
||||
Log::warn("Options", "preset PostFX \"{}\" no trobat; aplicant passthrough.", g_video.shader.current_postfx_preset);
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user