util/file: cleanup log initialization and some file-util functions (#2299)

Fixes both issues mentioned in #2297
This commit is contained in:
Tyler Wilding
2023-03-01 17:52:33 -05:00
committed by GitHub
parent 43da4088e6
commit bc40fc5d2f
9 changed files with 76 additions and 32 deletions
+7 -2
View File
@@ -35,7 +35,7 @@
void setup_logging(bool verbose, std::string log_file) {
if (!log_file.empty()) {
lg::set_file(log_file);
lg::set_file(log_file, false);
}
if (verbose) {
lg::set_file_level(lg::level::debug);
@@ -68,7 +68,12 @@ int main(int argc, char** argv) {
AppState appstate;
LSPRouter lsp_router;
appstate.verbose = verbose;
setup_logging(appstate.verbose, logfile);
try {
setup_logging(appstate.verbose, logfile);
} catch (const std::exception& e) {
lg::error("Failed to setup logging: {}", e.what());
return 1;
}
lsp_router.init_routes();
lg::info("OpenGOAL LSP Initialized, ready for requests");