feat: Update 4 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m12s
Build-Test-Publish / build (linux/arm64) (push) Successful in 3m49s

This commit is contained in:
Your Name
2025-09-01 20:05:35 +12:00
parent aea0f0f307
commit 622ea5d83d
4 changed files with 84 additions and 7 deletions

View File

@@ -47,7 +47,8 @@ bool config::load_config() { // load json config file.
"server_definition_paths",
"template_local_paths",
"template_registries",
"backups_path"
"backups_path",
"log_level"
};
std::set<std::string> deprecated_fields = {
@@ -107,8 +108,24 @@ bool config::load_config() { // load json config file.
}
}
}
// Validate log_level if present
if (mConfig.contains("log_level")) {
if (!mConfig["log_level"].is_string()) {
error << "'log_level' must be a string" << std::endl;
return false;
}
std::string log_level = mConfig["log_level"];
std::set<std::string> valid_levels = {"debug", "info", "warning", "error"};
if (valid_levels.find(log_level) == valid_levels.end()) {
error << "Invalid log_level '" << log_level << "'" << std::endl;
error << "Valid levels are: debug, info, warning, error" << std::endl;
return false;
}
}
mIsConfigSet = true;
apply_log_level(); // Apply the log level from config
return true;
}
@@ -154,6 +171,7 @@ bool config::save_config(bool create_aux_directories)
mConfig["backups_path"] = {
dropshell_base + "/backups"
};
mConfig["log_level"] = "info"; // Default log level
}
config_file << mConfig.dump(4);
@@ -275,4 +293,18 @@ tRegistryEntry::~tRegistryEntry()
{
}
std::string config::get_log_level() const
{
if (!mIsConfigSet || !mConfig.contains("log_level"))
return "info"; // Default log level
return mConfig["log_level"];
}
void config::apply_log_level()
{
std::string level = get_log_level();
set_log_level(level);
}
} // namespace dropshell