summaryrefslogtreecommitdiff
path: root/Source/Core/Common/LogManager.cpp
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2014-02-11 14:10:59 +0100
committerdegasus <wickmarkus@web.de>2014-04-14 10:39:52 +0200
commitee76a51d1f7062661e236caa39a1031e4608b587 (patch)
tree430aeb417565182cf71abf268b2cfcdfe10fb7ca /Source/Core/Common/LogManager.cpp
parent4f3227b4a94de2e149ce90edaaea40cc83b3c41a (diff)
Truncate the path on logging
Cmake compiles we an absolute path, so the macro __FILE__ also has the absolute file in it. It seems that gcc doesn't provide macros for the basename, so we have to truncate them in c directly: https://stackoverflow.com/questions/8487986/file-macro-shows-full-path
Diffstat (limited to 'Source/Core/Common/LogManager.cpp')
-rw-r--r--Source/Core/Common/LogManager.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Core/Common/LogManager.cpp b/Source/Core/Common/LogManager.cpp
index bc4f9300c6..cb86d045d7 100644
--- a/Source/Core/Common/LogManager.cpp
+++ b/Source/Core/Common/LogManager.cpp
@@ -22,6 +22,19 @@
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *file, int line, const char* fmt, ...)
{
+#ifdef _WIN32
+ int delimiter = '\\';
+#else
+ int delimiter = '/';
+#endif
+ // The used macro __FILE__ differs between GCC and VS:
+ // GCC defines the full path, VS relative to the local project file.
+ // It would be the best to get the one relative to the project directory,
+ // but the full path is even worse, so just strip it to the filename itself.
+ const char* basefile = strrchr(file, delimiter);
+ if(basefile != nullptr)
+ file = basefile + 1;
+
va_list args;
va_start(args, fmt);
if (LogManager::GetInstance())