From d811231db047df9eb8cf17164ad83698f61d6f2a Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Fri, 1 Mar 2024 19:41:13 +0100 Subject: [PATCH] Fixed log directory detection --- source/Enderal DLL/src/Main.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index 69a38ed4..cc12988d 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -1,5 +1,5 @@ -#include "EventListener.h" #include "Util.h" +#include "EventListener.h" #include "Papyrus.h" #include "Patches/MainMenuPatch.h" #include "Patches/FlatMapMarkers.h" @@ -27,14 +27,26 @@ static std::map g_settings{ namespace { void InitializeLogging() { - auto path = logger::log_directory(); - if (!path) { - SKSE::stl::report_and_fail("Failed to find standard logging directory"sv); + wchar_t* buffer{ nullptr }; + const auto result = ::SHGetKnownFolderPath(::FOLDERID_Documents, ::KNOWN_FOLDER_FLAG::KF_FLAG_DEFAULT, nullptr, std::addressof(buffer)); + std::unique_ptr knownPath(buffer, ::CoTaskMemFree); + + if (!knownPath || result != S_OK) { + logger::error("failed to get known folder path"sv); + return; } - *path /= "EnderalSE.log"sv; - auto sink = std::make_shared(path->string(), true); + std::filesystem::path path = knownPath.get(); + path /= "My Games"sv; + if (GetModuleHandle(L"Galaxy64.dll") != NULL) { + path /= "Skyrim Special Edition GOG"sv; + } else { + path /= "Skyrim Special Edition"sv; + } + path /= "SKSE"sv; + path /= "EnderalSE.log"sv; + auto sink = std::make_shared(path.string(), true); auto log = std::make_shared("global log"s, std::move(sink)); log->set_level(spdlog::level::info);