summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Logging/LogManager.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2018-08-28 11:48:43 +0200
committerJosJuice <josjuice@gmail.com>2018-08-28 11:48:43 +0200
commitfbdc239199d838afb5cdd175d9002909686155ed (patch)
tree8408aebc0f935608893fc3e3dd89602017c1781b /Source/Core/Common/Logging/LogManager.cpp
parent762747f8c145b0e1c66879ad98cc15888fe2b92d (diff)
Fix reducing log paths when building with MSVC
The LogManager code had trouble detecting the "/Source/Core/" substring for two reasons, neither of which seemed to happen a few years ago: 1. __FILE__ is in lowercase on MSVC 2. __FILE__ uses backslash as the directory separator on MSVC Fixes https://bugs.dolphin-emu.org/issues/11366
Diffstat (limited to 'Source/Core/Common/Logging/LogManager.cpp')
-rw-r--r--Source/Core/Common/Logging/LogManager.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp
index 5541fce843..cd108b0f46 100644
--- a/Source/Core/Common/Logging/LogManager.cpp
+++ b/Source/Core/Common/Logging/LogManager.cpp
@@ -2,8 +2,10 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include <algorithm>
#include <cstdarg>
#include <cstring>
+#include <locale>
#include <mutex>
#include <ostream>
#include <string>
@@ -67,8 +69,18 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char*
static size_t DeterminePathCutOffPoint()
{
- constexpr const char* pattern = DIR_SEP "Source" DIR_SEP "Core" DIR_SEP;
- size_t pos = std::string(__FILE__).find(pattern);
+ constexpr const char* pattern = "/source/core/";
+#ifdef _WIN32
+ constexpr const char* pattern2 = "\\source\\core\\";
+#endif
+ std::string path = __FILE__;
+ std::transform(path.begin(), path.end(), path.begin(),
+ [](char c) { return std::tolower(c, std::locale::classic()); });
+ size_t pos = path.find(pattern);
+#ifdef _WIN32
+ if (pos == std::string::npos)
+ pos = path.find(pattern2);
+#endif
if (pos != std::string::npos)
return pos + strlen(pattern);
return 0;