Log YAML syntax error on .conf files

This commit is contained in:
Victor Mataré 2022-11-19 18:00:26 +01:00
parent 9267a7e60d
commit 3811265786
2 changed files with 9 additions and 1 deletions

View File

@ -202,6 +202,11 @@ const Config *Config::try_read_config(const string &filename)
} );
if (ext == ".YAML")
throw ConfigError(filename, e.mark, f_data, e.what());
else {
log(TF_INF) << "Config file " << filename << " could not be parsed as YAML." << flush;
log(TF_DBG) << ConfigError(filename, e.mark, f_data, e.what()).what() << flush;
log(TF_INF) << "Attempting to parse with legacy syntax because filename does not end in .yaml..." << flush;
}
}
#endif //USE_YAML

View File

@ -362,14 +362,17 @@ int main(int argc, char **argv) {
if (daemonize) {
{
// Test the config before forking
unique_ptr<const Config> test_cfg(Config::read_config(config_files));
LogLevel old_lvl = Logger::instance().log_lvl();
Logger::instance().log_lvl() = TF_ERR;
unique_ptr<const Config> test_cfg(Config::read_config(config_files));
temp_state = TemperatureState(test_cfg->num_temps());
test_cfg->init_sensors(temp_state);
test_cfg->init_fans();
for (auto &sensor : test_cfg->sensors())
sensor->read_temps();
Logger::instance().log_lvl() = old_lvl;
// Own scope so the config gets destroyed before forking
}