diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index a24a0bbc9a..5d15998398 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -9,6 +9,7 @@ #include #include +#include "Common/CommonPaths.h" #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/Logging/ConsoleListener.h" @@ -29,6 +30,15 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* LogManager* LogManager::m_logManager = nullptr; +static size_t DeterminePathCutOffPoint() +{ + constexpr const char* pattern = DIR_SEP "Source" DIR_SEP "Core" DIR_SEP; + size_t pos = std::string(__FILE__).find(pattern); + if (pos != std::string::npos) + return pos + strlen(pattern); + return 0; +} + LogManager::LogManager() { // create log containers @@ -102,6 +112,8 @@ LogManager::LogManager() if (enable && write_console) container->AddListener(LogListener::CONSOLE_LISTENER); } + + m_path_cutoff_point = DeterminePathCutOffPoint(); } LogManager::~LogManager() @@ -125,8 +137,10 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const CharArrayFromFormatV(temp, MAX_MSGLEN, format, args); + const char* path_to_print = file + m_path_cutoff_point; + std::string msg = StringFromFormat( - "%s %s:%u %c[%s]: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, + "%s %s:%u %c[%s]: %s\n", Common::Timer::GetTimeFormatted().c_str(), path_to_print, line, LogTypes::LOG_LEVEL_TO_CHAR[(int)level], log->GetShortName().c_str(), temp); for (auto listener_id : *log) diff --git a/Source/Core/Common/Logging/LogManager.h b/Source/Core/Common/Logging/LogManager.h index 1c5081cf60..ea7f2d86a3 100644 --- a/Source/Core/Common/Logging/LogManager.h +++ b/Source/Core/Common/Logging/LogManager.h @@ -87,6 +87,7 @@ private: LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; static LogManager* m_logManager; // Singleton. Ugh. std::array m_listeners; + size_t m_path_cutoff_point = 0; LogManager(); ~LogManager();