fix(config): parse config after logging initialized (#3769)

This commit is contained in:
ReenigneArcher
2025-03-30 15:33:39 -04:00
committed by GitHub
parent f921ae45d4
commit 5f9fe26df3
2 changed files with 10 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -106,10 +106,6 @@ int main(int argc, char *argv[]) {
mail::man = std::make_shared<safe::mail_raw_t>();
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)) {