From 11cf47c4c247abfb65449f8de05cc302b059e3fb Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Wed, 14 Oct 2026 16:25:29 +0800 Subject: [PATCH] Feat: add logging for config parse and access errors - Log parse failures in the Config constructor via spdlog::error - Log missing keys and type mismatches (error when throwing, warn when falling back to defaults) --- includes/JuiceAgent/Config.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/JuiceAgent/Config.hpp b/includes/JuiceAgent/Config.hpp index 97297be..3c59cf2 100644 --- a/includes/JuiceAgent/Config.hpp +++ b/includes/JuiceAgent/Config.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace JuiceAgent::Config { @@ -37,7 +38,7 @@ public: _config = toml::parse_file(_config_path.string()); _valid = true; } catch (const toml::parse_error& e) { - // TODO: Log the error + spdlog::error("Failed to parse config file: {}", e.what()); _last_error = e; } } @@ -48,7 +49,7 @@ public: const auto* node = _config.at_path(path).node(); if (!node) { - // TODO: Log the error + spdlog::error("Configuration key not found: {}", path); throw std::runtime_error( "Configuration key not found: " + path ); @@ -57,7 +58,7 @@ public: auto value = node->value(); if (!value) { - // TODO: Log the error + spdlog::error("Configuration type mismatch: {}", path); throw std::runtime_error( "Configuration type mismatch: " + path ); @@ -72,7 +73,7 @@ public: if (!node) { // Configuration key is missing; use the default value. - // TODO: Log the warning + spdlog::warn("Configuration key not found: {}, using default value", path); return defaultValue; } @@ -80,7 +81,7 @@ public: if (!value) { // Configuration type mismatch; use the default value. - // TODO: Log the warning + spdlog::warn("Configuration type mismatch: {}, using default value", path); return defaultValue; }