aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-09-19 23:33:49 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-09-19 23:33:49 +0100
commitad9fc6dda75ced36476d7a6a931d556a3470cefb (patch)
tree3759755cafaea6545e5d8ef2237b89f941c48587 /NorthstarDLL
parent9a35efe0b0f5e632d4f182dc490a587390539392 (diff)
downloadNorthstarLauncher-ad9fc6dda75ced36476d7a6a931d556a3470cefb.tar.gz
NorthstarLauncher-ad9fc6dda75ced36476d7a6a931d556a3470cefb.zip
set launcher directory and error on fail creating log files
Diffstat (limited to 'NorthstarDLL')
-rw-r--r--NorthstarDLL/logging.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/NorthstarDLL/logging.cpp b/NorthstarDLL/logging.cpp
index 7c6d50a6..99179d26 100644
--- a/NorthstarDLL/logging.cpp
+++ b/NorthstarDLL/logging.cpp
@@ -219,14 +219,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);
+ }
}
}