diff --git a/src/config.cpp b/src/config.cpp index 54eb5236..901e1cae 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -653,7 +653,7 @@ namespace config { if (*begin_val == '[') { endl = skip_list(begin_val + 1, end); if (endl == end) { - std::cout << "Warning: Config option ["sv << to_string(begin, end_name) << "] Missing ']'"sv; + BOOST_LOG(warning) << "config: Missing ']' in config option: " << to_string(begin, end_name); return std::make_pair(endl, std::nullopt); } @@ -988,7 +988,7 @@ namespace config { // The list needs to be a multiple of 2 if (list.size() % 2) { - std::cout << "Warning: expected "sv << name << " to have a multiple of two elements --> not "sv << list.size() << std::endl; + BOOST_LOG(warning) << "config: expected "sv << name << " to have a multiple of two elements --> not "sv << list.size(); return; } @@ -1018,7 +1018,7 @@ namespace config { config::sunshine.flags[config::flag::UPNP].flip(); break; default: - std::cout << "Warning: Unrecognized flag: ["sv << *line << ']' << std::endl; + BOOST_LOG(warning) << "config: Unrecognized flag: ["sv << *line << ']' << std::endl; ret = -1; } @@ -1044,7 +1044,7 @@ namespace config { } for (auto &[name, val] : vars) { - std::cout << "["sv << name << "] -- ["sv << val << ']' << std::endl; + BOOST_LOG(info) << "config: '"sv << name << "' = "sv << val; } int_f(vars, "qp", video.qp); @@ -1425,7 +1425,7 @@ namespace config { shell_exec_info.nShow = SW_NORMAL; if (!ShellExecuteExW(&shell_exec_info)) { auto winerr = GetLastError(); - std::cout << "Error: ShellExecuteEx() failed:"sv << winerr << std::endl; + BOOST_LOG(error) << "Failed executing shell command: " << winerr << std::endl; return 1; } diff --git a/src/main.cpp b/src/main.cpp index 04b080c5..555366ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,10 +106,6 @@ int main(int argc, char *argv[]) { mail::man = std::make_shared(); - if (config::parse(argc, argv)) { - return 0; - } - auto log_deinit_guard = logging::init(config::sunshine.min_log_level, config::sunshine.log_file); if (!log_deinit_guard) { BOOST_LOG(error) << "Logging failed to initialize"sv; @@ -123,6 +119,11 @@ int main(int argc, char *argv[]) { // Log publisher metadata log_publisher_data(); + // parse config file + if (config::parse(argc, argv)) { + return 0; + } + if (!config::sunshine.cmd.name.empty()) { auto fn = cmd_to_func.find(config::sunshine.cmd.name); if (fn == std::end(cmd_to_func)) {