aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp0358 <p0358@users.noreply.github.com>2022-09-19 01:56:12 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-20 00:07:04 +0200
commite7325406e1e8a4f42da094ba1c1256d7c9c2fbcb (patch)
treea4791ec6bacaa13068a7dabe9b78a5b38a7e53e4
parent6b84f1d4e37dfcca2e48acd5a3968707c23d568b (diff)
downloadNorthstarLauncher-e7325406e1e8a4f42da094ba1c1256d7c9c2fbcb.tar.gz
NorthstarLauncher-e7325406e1e8a4f42da094ba1c1256d7c9c2fbcb.zip
Display error if logs path isn't writeable (#274)
-rw-r--r--NorthstarDLL/logging.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/NorthstarDLL/logging.cpp b/NorthstarDLL/logging.cpp
index 38d58fa0..4d277767 100644
--- a/NorthstarDLL/logging.cpp
+++ b/NorthstarDLL/logging.cpp
@@ -19,14 +19,23 @@ void CreateLogFiles()
}
else
{
- // todo: might be good to delete logs that are too old
- time_t time = std::time(nullptr);
- tm currentTime = *std::localtime(&time);
- std::stringstream stream;
-
- stream << std::put_time(&currentTime, (GetNorthstarPrefix() + "/logs/nslog%Y-%m-%d %H-%M-%S.txt").c_str());
- spdlog::default_logger()->sinks().push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(stream.str(), false));
- spdlog::flush_on(spdlog::level::info);
+ try
+ {
+ // todo: might be good to delete logs that are too old
+ time_t time = std::time(nullptr);
+ tm currentTime = *std::localtime(&time);
+ std::stringstream stream;
+
+ stream << std::put_time(&currentTime, (GetNorthstarPrefix() + "/logs/nslog%Y-%m-%d %H-%M-%S.txt").c_str());
+ spdlog::default_logger()->sinks().push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(stream.str(), false));
+ spdlog::flush_on(spdlog::level::info);
+ }
+ catch (...)
+ {
+ spdlog::error("Failed creating log file");
+ MessageBoxA(
+ 0, "Failed creating log file! Make sure the profile directory is writable.", "Northstar Warning", MB_ICONWARNING | MB_OK);
+ }
}
}