Skip to content

Commit

Permalink
Log YAML syntax error on .conf files
Browse files Browse the repository at this point in the history
  • Loading branch information
vmatare committed Nov 19, 2022
1 parent 9267a7e commit 3811265
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/thinkfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3811265

Please sign in to comment.