From 97e08f7988cb06348ebe8df988a7aa8d9b13e1ff Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 21 Feb 2021 12:40:47 +0100 Subject: [PATCH] Create log file in process dir instead of current working dir --- DDrawCompat/Common/Log.cpp | 4 ++-- DDrawCompat/Common/Log.h | 2 +- DDrawCompat/Dll/DllMain.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DDrawCompat/Common/Log.cpp b/DDrawCompat/Common/Log.cpp index 425d16f..828ea71 100644 --- a/DDrawCompat/Common/Log.cpp +++ b/DDrawCompat/Common/Log.cpp @@ -76,7 +76,7 @@ namespace Compat s_logFile << std::endl; } - void Log::initLogging(std::string processName) + void Log::initLogging(const std::string& processDir, std::string processName) { if (processName.length() >= 4 && 0 == _strcmpi(processName.substr(processName.length() - 4).c_str(), ".exe")) @@ -87,7 +87,7 @@ namespace Compat for (int i = 1; i < 100; ++i) { std::ostringstream logFileName; - logFileName << "DDrawCompat-" << processName; + logFileName << processDir << '\\' << "DDrawCompat-" << processName; if (i > 1) { logFileName << '[' << i << ']'; diff --git a/DDrawCompat/Common/Log.h b/DDrawCompat/Common/Log.h index 8c1e6e1..f0572ec 100644 --- a/DDrawCompat/Common/Log.h +++ b/DDrawCompat/Common/Log.h @@ -166,7 +166,7 @@ namespace Compat return *this; } - static void initLogging(std::string processName); + static void initLogging(const std::string& processDir, std::string processName); static bool isPointerDereferencingAllowed() { return s_isLeaveLog || 0 == s_outParamDepth; } protected: diff --git a/DDrawCompat/Dll/DllMain.cpp b/DDrawCompat/Dll/DllMain.cpp index 98869d2..a33612f 100644 --- a/DDrawCompat/Dll/DllMain.cpp +++ b/DDrawCompat/Dll/DllMain.cpp @@ -230,7 +230,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) } auto processPath = getModulePath(nullptr); - Compat::Log::initLogging(getFileName(processPath)); + Compat::Log::initLogging(getDirName(processPath), getFileName(processPath)); Compat::Log() << "Process path: " << processPath; printEnvironmentVariable("__COMPAT_LAYER");