Merge pull request #4288 from aldelaro5/reduce-logged-filename
Reduce the filepath of logs
This commit is contained in:
commit
5d3853d854
|
@ -9,6 +9,7 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#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)
|
||||
|
|
|
@ -87,6 +87,7 @@ private:
|
|||
LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
|
||||
static LogManager* m_logManager; // Singleton. Ugh.
|
||||
std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners;
|
||||
size_t m_path_cutoff_point = 0;
|
||||
|
||||
LogManager();
|
||||
~LogManager();
|
||||
|
|
Loading…
Reference in New Issue