From 3811265786746fb13b6b11814971a7e996716b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Matar=C3=A9?= Date: Sat, 19 Nov 2022 18:00:26 +0100 Subject: [PATCH] Log YAML syntax error on .conf files --- src/config.cpp | 5 +++++ src/thinkfan.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 120b79c..49af4b7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -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 diff --git a/src/thinkfan.cpp b/src/thinkfan.cpp index 60bf00a..0c624cc 100644 --- a/src/thinkfan.cpp +++ b/src/thinkfan.cpp @@ -362,14 +362,17 @@ int main(int argc, char **argv) { if (daemonize) { { // Test the config before forking + unique_ptr test_cfg(Config::read_config(config_files)); + LogLevel old_lvl = Logger::instance().log_lvl(); Logger::instance().log_lvl() = TF_ERR; - unique_ptr 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 }