diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-09-19 23:33:49 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-09-19 23:33:49 +0100 |
commit | ad9fc6dda75ced36476d7a6a931d556a3470cefb (patch) | |
tree | 3759755cafaea6545e5d8ef2237b89f941c48587 /NorthstarDLL/logging.cpp | |
parent | 9a35efe0b0f5e632d4f182dc490a587390539392 (diff) | |
download | NorthstarLauncher-ad9fc6dda75ced36476d7a6a931d556a3470cefb.tar.gz NorthstarLauncher-ad9fc6dda75ced36476d7a6a931d556a3470cefb.zip |
set launcher directory and error on fail creating log files
Diffstat (limited to 'NorthstarDLL/logging.cpp')
-rw-r--r-- | NorthstarDLL/logging.cpp | 25 |
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(¤tTime, (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(¤tTime, (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); + } } } |