refactor(log): migra core/input i core/audio a Log::
- gamepad_manager.cpp (12 logs): connect/disconnect com a info, errors d'open/init com a error, warning per BD no carregada. - key_config.cpp (5 logs): error per arxius malformats, info per al recompte de bindings carregats. - gamepad_bindings.cpp (4 logs): error/info anàleg. - audio_effects.cpp (2 errors de format). - sound_effects_config.cpp (3 logs): warn quan no hi ha presets, error de parse. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6e99fd0a8b
commit
0b708f1515
5 files changed
+30
-41
No files matched your search
@@ -1,11 +1,11 @@
|
||||
#include "core/input/key_config.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "core/resources/resource_helper.hpp"
|
||||
#include "external/fkyaml_node.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
auto KeyConfig::get() -> KeyConfig& {
|
||||
static KeyConfig instance_;
|
||||
@@ -15,7 +15,7 @@ auto KeyConfig::get() -> KeyConfig& {
|
||||
void KeyConfig::load(const std::string& file_path) {
|
||||
auto bytes = Resource::Helper::loadFile(file_path);
|
||||
if (bytes.empty()) {
|
||||
std::cerr << "KeyConfig: no s'ha pogut obrir " << file_path << '\n';
|
||||
Log::error("KeyConfig", "no s'ha pogut obrir {}", file_path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ void KeyConfig::load(const std::string& file_path) {
|
||||
const auto* end = begin + bytes.size();
|
||||
auto yaml = fkyaml::node::deserialize(begin, end);
|
||||
if (!yaml.contains("keys") || !yaml["keys"].is_sequence()) {
|
||||
std::cerr << "KeyConfig: falta la secció 'keys' a " << file_path << '\n';
|
||||
Log::error("KeyConfig", "falta la secció 'keys' a {}", file_path);
|
||||
return;
|
||||
}
|
||||
bindings_.clear();
|
||||
@@ -34,14 +34,14 @@ void KeyConfig::load(const std::string& file_path) {
|
||||
const auto CODE = entry["code"].get_value<std::string>();
|
||||
const SDL_Scancode SC = SDL_GetScancodeFromName(CODE.c_str());
|
||||
if (SC == SDL_SCANCODE_UNKNOWN) {
|
||||
std::cerr << "KeyConfig: codi SDL desconegut '" << CODE << "' per id '" << ID << "'\n";
|
||||
Log::warn("KeyConfig", "codi SDL desconegut '{}' per id '{}'", CODE, ID);
|
||||
continue;
|
||||
}
|
||||
bindings_[ID] = SC;
|
||||
}
|
||||
std::cout << "KeyConfig: " << bindings_.size() << " bindings des de " << file_path << '\n';
|
||||
Log::info("KeyConfig", "{} bindings des de {}", bindings_.size(), file_path);
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "KeyConfig: error parsejant " << file_path << ": " << e.what() << '\n';
|
||||
Log::error("KeyConfig", "error parsejant {}: {}", file_path, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user