Commit e949b77e authored by Libretro-Admin's avatar Libretro-Admin
Browse files

(Libretro) Further simplifications to LogManagerLibretro

parent 9d1d21f4
Pipeline #16337 passed with stages
in 2 minutes and 15 seconds
......@@ -23,7 +23,8 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char*
va_list args;
va_start(args, fmt);
if (s_log_manager)
s_log_manager->LogWithFullPath(level, type, file, line, fmt, args);
if (s_log_manager->IsEnabled(type, level))
s_log_manager->LogWithFullPath(level, type, file, line, fmt, args);
va_end(args);
}
......@@ -96,9 +97,17 @@ LogManager::~LogManager()
{
}
void LogManager::LogLibretro(LogTypes::LOG_LEVELS level, const char* text)
void LogManager::LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char* file_, int line, const char* format, va_list args)
{
const char *file = file_ + m_path_cutoff_point;
char temp[MAX_MSGLEN];
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
std::string msg =
StringFromFormat("%s:%u %c[%s]: %s\n", file,
line, LogTypes::LOG_LEVEL_TO_CHAR[(int)level], GetShortName(type), temp);
retro_log_level retro_level;
const char *text = msg.c_str();
switch (level)
{
case LogTypes::LNOTICE:
......@@ -120,22 +129,6 @@ void LogManager::LogLibretro(LogTypes::LOG_LEVELS level, const char* text)
retro_printf(retro_level, "%s", text);
}
void LogManager::LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char* file_, int line, const char* format, va_list args)
{
if (!IsEnabled(type, level))
return;
const char *file = file_ + m_path_cutoff_point;
char temp[MAX_MSGLEN];
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
std::string msg =
StringFromFormat("%s:%u %c[%s]: %s\n", file,
line, LogTypes::LOG_LEVEL_TO_CHAR[(int)level], GetShortName(type), temp);
LogLibretro(level, msg.c_str());
}
void LogManager::SetLogLevel(LogTypes::LOG_LEVELS level)
{
m_level = level;
......
......@@ -47,8 +47,6 @@ private:
LogManager(LogManager&&) = delete;
LogManager& operator=(LogManager&&) = delete;
void LogLibretro(LogTypes::LOG_LEVELS level, const char* text);
LogTypes::LOG_LEVELS m_level;
std::array<LogContainer, LogTypes::NUMBER_OF_LOGS> m_log{};
size_t m_path_cutoff_point = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment