From 1025bbcf89ee5909d78012f23c7ea229859af2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 25 Aug 2023 11:33:48 +0200 Subject: [PATCH 1/3] Log level/type: Use enum class instead of the awkward namespace trick. Just a small cleanup I've wanted to do for a long time. --- Common/ConsoleListener.cpp | 37 ++++----- Common/ConsoleListener.h | 4 +- Common/Log.h | 27 +++--- Common/LogManager.cpp | 96 +++++++++++----------- Common/LogManager.h | 36 ++++---- Core/Debugger/WebSocket.cpp | 6 +- Core/Debugger/WebSocket/LogBroadcaster.cpp | 2 +- Core/Debugger/WebSocket/WebSocketUtils.h | 8 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 6 +- Core/FileSystems/VirtualDiscFileSystem.h | 4 +- Core/HLE/HLE.cpp | 2 +- Core/HLE/HLE.h | 20 ++--- UI/DevScreens.cpp | 24 +++--- UI/NativeApp.cpp | 22 ++--- UWP/PPSSPP_UWPMain.cpp | 2 +- Windows/main.cpp | 2 +- android/jni/app-android.cpp | 4 +- headless/Headless.cpp | 18 ++-- libretro/libretro.cpp | 14 ++-- 19 files changed, 163 insertions(+), 171 deletions(-) diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index d83d800b3b23..86fe3e07a6fc 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -358,7 +358,7 @@ void ConsoleListener::LogWriterThread() for (char *Text = logLocal, *End = logLocal + logLocalSize; Text < End; ) { - LogTypes::LOG_LEVELS Level = LogTypes::LINFO; + LogLevel Level = LogLevel::LINFO; char *next = (char *) memchr(Text + 1, '\033', End - Text); size_t Len = next - Text; @@ -367,7 +367,7 @@ void ConsoleListener::LogWriterThread() if (Text[0] == '\033' && Text + 1 < End) { - Level = (LogTypes::LOG_LEVELS) (Text[1] - '0'); + Level = (LogLevel)(Text[1] - '0'); Len -= 2; Text += 2; } @@ -384,7 +384,7 @@ void ConsoleListener::LogWriterThread() delete [] logLocal; } -void ConsoleListener::SendToThread(LogTypes::LOG_LEVELS Level, const char *Text) +void ConsoleListener::SendToThread(LogLevel Level, const char *Text) { // Oops, we're already quitting. Just do nothing. if (logPendingWritePos == (u32) -1) @@ -462,7 +462,7 @@ void ConsoleListener::SendToThread(LogTypes::LOG_LEVELS Level, const char *Text) SetEvent(hTriggerEvent); } -void ConsoleListener::WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Text, size_t Len) +void ConsoleListener::WriteToConsole(LogLevel Level, const char *Text, size_t Len) { _dbg_assert_msg_(IsOpen(), "Don't call this before opening the console."); @@ -479,21 +479,20 @@ void ConsoleListener::WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Tex WORD Color; static wchar_t tempBuf[2048]; - switch (Level) - { - case NOTICE_LEVEL: // light green + switch (Level) { + case LogLevel::LNOTICE: // light green Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; - case ERROR_LEVEL: // light red + case LogLevel::LERROR: // light red Color = FOREGROUND_RED | FOREGROUND_INTENSITY; break; - case WARNING_LEVEL: // light yellow + case LogLevel::LWARNING: // light yellow Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; - case INFO_LEVEL: // cyan + case LogLevel::LINFO: // cyan Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break; - case DEBUG_LEVEL: // gray + case LogLevel::LDEBUG: // gray Color = FOREGROUND_INTENSITY; break; default: // off-white @@ -593,7 +592,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool COORD Coo = GetCoordinates(OldCursor, LBufWidth); SetConsoleCursorPosition(hConsole, Coo); - // if (SLog.length() > 0) Log(LogTypes::LNOTICE, SLog.c_str()); + // if (SLog.length() > 0) Log(LogLevel::LNOTICE, SLog.c_str()); // Resize the window too if (Resize) MoveWindow(GetConsoleWindow(), Left,Top, (Width + 100),Height, true); @@ -615,18 +614,16 @@ void ConsoleListener::Log(const LogMessage &msg) { char ColorAttr[16] = ""; char ResetAttr[16] = ""; - if (bUseColor) - { + if (bUseColor) { strcpy(ResetAttr, "\033[0m"); - switch (msg.level) - { - case NOTICE_LEVEL: // light green + switch (msg.level) { + case LogLevel::LNOTICE: // light green strcpy(ColorAttr, "\033[92m"); break; - case ERROR_LEVEL: // light red + case LogLevel::LERROR: // light red strcpy(ColorAttr, "\033[91m"); break; - case WARNING_LEVEL: // light yellow + case LogLevel::LWARNING: // light yellow strcpy(ColorAttr, "\033[93m"); break; default: @@ -656,5 +653,3 @@ void ConsoleListener::ClearScreen(bool Cursor) if (Cursor) SetConsoleCursorPosition(hConsole, coordScreen); #endif } - - diff --git a/Common/ConsoleListener.h b/Common/ConsoleListener.h index 99c673075015..a84bb257656f 100644 --- a/Common/ConsoleListener.h +++ b/Common/ConsoleListener.h @@ -54,8 +54,8 @@ class ConsoleListener : public LogListener { static unsigned int WINAPI RunThread(void *lpParam); void LogWriterThread(); - void SendToThread(LogTypes::LOG_LEVELS Level, const char *Text); - void WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Text, size_t Len); + void SendToThread(LogLevel Level, const char *Text); + void WriteToConsole(LogLevel Level, const char *Text, size_t Len); static int refCount; static HANDLE hThread; diff --git a/Common/Log.h b/Common/Log.h index 50be16ba9a2a..b272f476c16b 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -26,9 +26,7 @@ #define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. #define VERBOSE_LEVEL 6 // Noisy debugging - sometimes needed but usually unimportant. -namespace LogTypes { - -enum LOG_TYPE { +enum class LogType { SYSTEM = 0, // Catch-all for uncategorized things BOOT, COMMON, @@ -67,7 +65,7 @@ enum LOG_TYPE { ACHIEVEMENTS = HLE, // TODO: Make a real category }; -enum LOG_LEVELS : int { +enum class LogLevel : int { LNOTICE = NOTICE_LEVEL, LERROR = ERROR_LEVEL, LWARNING = WARNING_LEVEL, @@ -76,19 +74,18 @@ enum LOG_LEVELS : int { LVERBOSE = VERBOSE_LEVEL, }; -} // namespace - -void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, +void GenericLog(LogLevel level, LogType type, const char *file, int line, const char *fmt, ...) #ifdef __GNUC__ __attribute__((format(printf, 5, 6))) #endif ; -bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type); +bool GenericLogEnabled(LogLevel level, LogType type); // Exception for Windows - enable more log levels in release mode than on other platforms. #if defined(_DEBUG) || defined(_WIN32) +// Needs to be an int (and not use the enum) because it's used by the preprocessor! #define MAX_LOGLEVEL DEBUG_LEVEL #else @@ -102,16 +99,16 @@ bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type); // Let the compiler optimize this out. // TODO: Compute a dynamic max level as well that can be checked here. #define GENERIC_LOG(t, v, ...) { \ - if (v <= MAX_LOGLEVEL) \ + if ((int)v <= MAX_LOGLEVEL) \ GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ } -#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (false) -#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (false) -#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (false) -#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (false) -#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (false) -#define VERBOSE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LVERBOSE, __VA_ARGS__) } while (false) +#define ERROR_LOG(t,...) do { GENERIC_LOG(LogType::t, LogLevel::LERROR, __VA_ARGS__) } while (false) +#define WARN_LOG(t,...) do { GENERIC_LOG(LogType::t, LogLevel::LWARNING, __VA_ARGS__) } while (false) +#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogType::t, LogLevel::LNOTICE, __VA_ARGS__) } while (false) +#define INFO_LOG(t,...) do { GENERIC_LOG(LogType::t, LogLevel::LINFO, __VA_ARGS__) } while (false) +#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogType::t, LogLevel::LDEBUG, __VA_ARGS__) } while (false) +#define VERBOSE_LOG(t,...) do { GENERIC_LOG(LogType::t, LogLevel::LVERBOSE, __VA_ARGS__) } while (false) // Currently only actually shows a dialog box on Windows. bool HandleAssert(const char *function, const char *file, int line, const char *expression, const char* format, ...) diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 13084098a41b..d12a253deebb 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -47,7 +47,7 @@ static const char level_to_char[8] = "-NEWIDV"; #define LOG_MSC_OUTPUTDEBUG false #endif -void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char* fmt, ...) { +void GenericLog(LogLevel level, LogType type, const char *file, int line, const char* fmt, ...) { if (g_bLogEnabledSetting && !(*g_bLogEnabledSetting)) return; va_list args; @@ -69,7 +69,7 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char va_end(args); } -bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type) { +bool GenericLogEnabled(LogLevel level, LogType type) { if (LogManager::GetInstance()) return (*g_bLogEnabledSetting) && LogManager::GetInstance()->IsEnabled(level, type); return false; @@ -78,55 +78,55 @@ bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type) { LogManager *LogManager::logManager_ = NULL; struct LogNameTableEntry { - LogTypes::LOG_TYPE logType; + LogType logType; const char *name; }; static const LogNameTableEntry logTable[] = { - {LogTypes::SYSTEM, "SYSTEM"}, - {LogTypes::BOOT, "BOOT"}, - {LogTypes::COMMON, "COMMON"}, - {LogTypes::CPU, "CPU"}, - {LogTypes::FILESYS, "FILESYS"}, - {LogTypes::G3D, "G3D"}, - {LogTypes::HLE, "HLE"}, - {LogTypes::JIT, "JIT"}, - {LogTypes::LOADER, "LOADER"}, - {LogTypes::ME, "ME"}, // Media Engine - {LogTypes::MEMMAP, "MEMMAP"}, - {LogTypes::SASMIX, "SASMIX"}, - {LogTypes::SAVESTATE, "SAVESTATE"}, - {LogTypes::FRAMEBUF, "FRAMEBUF"}, - {LogTypes::AUDIO, "AUDIO"}, - {LogTypes::IO, "IO"}, - - {LogTypes::SCEAUDIO, "SCEAUDIO"}, - {LogTypes::SCECTRL, "SCECTRL"}, - {LogTypes::SCEDISPLAY, "SCEDISP"}, - {LogTypes::SCEFONT, "SCEFONT"}, - {LogTypes::SCEGE, "SCEGE"}, - {LogTypes::SCEINTC, "SCEINTC"}, - {LogTypes::SCEIO, "SCEIO"}, - {LogTypes::SCEKERNEL, "SCEKERNEL"}, - {LogTypes::SCEMODULE, "SCEMODULE"}, - {LogTypes::SCENET, "SCENET"}, - {LogTypes::SCERTC, "SCERTC"}, - {LogTypes::SCESAS, "SCESAS"}, - {LogTypes::SCEUTILITY, "SCEUTIL"}, - {LogTypes::SCEMISC, "SCEMISC"}, + {LogType::SYSTEM, "SYSTEM"}, + {LogType::BOOT, "BOOT"}, + {LogType::COMMON, "COMMON"}, + {LogType::CPU, "CPU"}, + {LogType::FILESYS, "FILESYS"}, + {LogType::G3D, "G3D"}, + {LogType::HLE, "HLE"}, + {LogType::JIT, "JIT"}, + {LogType::LOADER, "LOADER"}, + {LogType::ME, "ME"}, // Media Engine + {LogType::MEMMAP, "MEMMAP"}, + {LogType::SASMIX, "SASMIX"}, + {LogType::SAVESTATE, "SAVESTATE"}, + {LogType::FRAMEBUF, "FRAMEBUF"}, + {LogType::AUDIO, "AUDIO"}, + {LogType::IO, "IO"}, + + {LogType::SCEAUDIO, "SCEAUDIO"}, + {LogType::SCECTRL, "SCECTRL"}, + {LogType::SCEDISPLAY, "SCEDISP"}, + {LogType::SCEFONT, "SCEFONT"}, + {LogType::SCEGE, "SCEGE"}, + {LogType::SCEINTC, "SCEINTC"}, + {LogType::SCEIO, "SCEIO"}, + {LogType::SCEKERNEL, "SCEKERNEL"}, + {LogType::SCEMODULE, "SCEMODULE"}, + {LogType::SCENET, "SCENET"}, + {LogType::SCERTC, "SCERTC"}, + {LogType::SCESAS, "SCESAS"}, + {LogType::SCEUTILITY, "SCEUTIL"}, + {LogType::SCEMISC, "SCEMISC"}, }; LogManager::LogManager(bool *enabledSetting) { g_bLogEnabledSetting = enabledSetting; for (size_t i = 0; i < ARRAY_SIZE(logTable); i++) { - _assert_msg_(i == logTable[i].logType, "Bad logtable at %i", (int)i); - truncate_cpy(log_[logTable[i].logType].m_shortName, logTable[i].name); - log_[logTable[i].logType].enabled = true; + _assert_msg_((LogType)i == logTable[i].logType, "Bad logtable at %i", (int)i); + truncate_cpy(log_[(size_t)logTable[i].logType].m_shortName, logTable[i].name); + log_[(size_t)logTable[i].logType].enabled = true; #if defined(_DEBUG) - log_[logTable[i].logType].level = LogTypes::LDEBUG; + log_[(size_t)logTable[i].logType].level = LogLevel::LDEBUG; #else - log_[logTable[i].logType].level = LogTypes::LINFO; + log_[(size_t)logTable[i].logType].level = LogLevel::LINFO; #endif } @@ -158,7 +158,7 @@ LogManager::LogManager(bool *enabledSetting) { } LogManager::~LogManager() { - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { + for (int i = 0; i < (int)LogType::NUMBER_OF_LOGS; ++i) { #if !defined(MOBILE_DEVICE) || defined(_DEBUG) RemoveListener(fileLog_); RemoveListener(consoleLog_); @@ -194,25 +194,25 @@ void LogManager::ChangeFileLog(const char *filename) { } void LogManager::SaveConfig(Section *section) { - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { + for (int i = 0; i < (int)LogType::NUMBER_OF_LOGS; i++) { section->Set((std::string(log_[i].m_shortName) + "Enabled").c_str(), log_[i].enabled); section->Set((std::string(log_[i].m_shortName) + "Level").c_str(), (int)log_[i].level); } } void LogManager::LoadConfig(const Section *section, bool debugDefaults) { - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { + for (int i = 0; i < (int)LogType::NUMBER_OF_LOGS; i++) { bool enabled = false; int level = 0; section->Get((std::string(log_[i].m_shortName) + "Enabled").c_str(), &enabled, true); - section->Get((std::string(log_[i].m_shortName) + "Level").c_str(), &level, debugDefaults ? (int)LogTypes::LDEBUG : (int)LogTypes::LERROR); + section->Get((std::string(log_[i].m_shortName) + "Level").c_str(), &level, (int)(debugDefaults ? LogLevel::LDEBUG : LogLevel::LERROR)); log_[i].enabled = enabled; - log_[i].level = (LogTypes::LOG_LEVELS)level; + log_[i].level = (LogLevel)level; } } -void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char *format, va_list args) { - const LogChannel &log = log_[type]; +void LogManager::Log(LogLevel level, LogType type, const char *file, int line, const char *format, va_list args) { + const LogChannel &log = log_[(size_t)type]; if (level > log.level || !log.enabled) return; @@ -268,8 +268,8 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const } } -bool LogManager::IsEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type) { - LogChannel &log = log_[type]; +bool LogManager::IsEnabled(LogLevel level, LogType type) { + LogChannel &log = log_[(size_t)type]; if (level > log.level || !log.enabled) return false; return true; diff --git a/Common/LogManager.h b/Common/LogManager.h index 3ee1347f424c..7151774067e1 100644 --- a/Common/LogManager.h +++ b/Common/LogManager.h @@ -37,7 +37,7 @@ extern const char *hleCurrentThreadName; struct LogMessage { char timestamp[16]; char header[64]; // Filename/thread/etc. in front. - LogTypes::LOG_LEVELS level; + LogLevel level; const char *log; std::string msg; // The actual log message. }; @@ -83,7 +83,7 @@ class RingbufferLogListener : public LogListener { int GetCount() const { return count_ < MAX_LOGS ? count_ : MAX_LOGS; } const char *TextAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].msg.c_str(); } - LogTypes::LOG_LEVELS LevelAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].level; } + LogLevel LevelAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].level; } private: enum { MAX_LOGS = 128 }; @@ -99,7 +99,7 @@ class RingbufferLogListener : public LogListener { struct LogChannel { char m_shortName[32]{}; - LogTypes::LOG_LEVELS level; + LogLevel level; bool enabled; }; @@ -114,7 +114,7 @@ class LogManager { LogManager(const LogManager &) = delete; void operator=(const LogManager &) = delete; - LogChannel log_[LogTypes::NUMBER_OF_LOGS]; + LogChannel log_[(size_t)LogType::NUMBER_OF_LOGS]; FileLogListener *fileLog_ = nullptr; ConsoleListener *consoleLog_ = nullptr; OutputDebugStringLogListener *debuggerLog_ = nullptr; @@ -128,33 +128,33 @@ class LogManager { void AddListener(LogListener *listener); void RemoveListener(LogListener *listener); - static u32 GetMaxLevel() { return MAX_LOGLEVEL; } - static int GetNumChannels() { return LogTypes::NUMBER_OF_LOGS; } + static u32 GetMaxLevel() { return (u32)MAX_LOGLEVEL; } + static int GetNumChannels() { return (int)LogType::NUMBER_OF_LOGS; } - void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, + void Log(LogLevel level, LogType type, const char *file, int line, const char *fmt, va_list args); - bool IsEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type); + bool IsEnabled(LogLevel level, LogType type); - LogChannel *GetLogChannel(LogTypes::LOG_TYPE type) { - return &log_[type]; + LogChannel *GetLogChannel(LogType type) { + return &log_[(size_t)type]; } - void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) { - log_[type].level = level; + void SetLogLevel(LogType type, LogLevel level) { + log_[(size_t)type].level = level; } - void SetAllLogLevels(LogTypes::LOG_LEVELS level) { - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { + void SetAllLogLevels(LogLevel level) { + for (int i = 0; i < (int)LogType::NUMBER_OF_LOGS; ++i) { log_[i].level = level; } } - void SetEnabled(LogTypes::LOG_TYPE type, bool enable) { - log_[type].enabled = enable; + void SetEnabled(LogType type, bool enable) { + log_[(size_t)type].enabled = enable; } - LogTypes::LOG_LEVELS GetLogLevel(LogTypes::LOG_TYPE type) { - return log_[type].level; + LogLevel GetLogLevel(LogType type) { + return log_[(size_t)type].level; } ConsoleListener *GetConsoleListener() const { diff --git a/Core/Debugger/WebSocket.cpp b/Core/Debugger/WebSocket.cpp index 1ba39ad0ecfe..c17aa57c7067 100644 --- a/Core/Debugger/WebSocket.cpp +++ b/Core/Debugger/WebSocket.cpp @@ -160,14 +160,14 @@ void HandleDebuggerRequest(const http::ServerRequest &request) { ws->SetTextHandler([&](const std::string &t) { JsonReader reader(t.c_str(), t.size()); if (!reader.ok()) { - ws->Send(DebuggerErrorEvent("Bad message: invalid JSON", LogTypes::LERROR)); + ws->Send(DebuggerErrorEvent("Bad message: invalid JSON", LogLevel::LERROR)); return; } const JsonGet root = reader.root(); const char *event = root ? root.getString("event", nullptr) : nullptr; if (!event) { - ws->Send(DebuggerErrorEvent("Bad message: no event property", LogTypes::LERROR, root)); + ws->Send(DebuggerErrorEvent("Bad message: no event property", LogLevel::LERROR, root)); return; } @@ -185,7 +185,7 @@ void HandleDebuggerRequest(const http::ServerRequest &request) { } }); ws->SetBinaryHandler([&](const std::vector &d) { - ws->Send(DebuggerErrorEvent("Bad message", LogTypes::LERROR)); + ws->Send(DebuggerErrorEvent("Bad message", LogLevel::LERROR)); }); while (ws->Process(highActivity ? 1.0f / 1000.0f : 1.0f / 60.0f)) { diff --git a/Core/Debugger/WebSocket/LogBroadcaster.cpp b/Core/Debugger/WebSocket/LogBroadcaster.cpp index 07070be7b014..b3d4359c8981 100644 --- a/Core/Debugger/WebSocket/LogBroadcaster.cpp +++ b/Core/Debugger/WebSocket/LogBroadcaster.cpp @@ -95,7 +95,7 @@ struct DebuggerLogEvent { j.writeString("timestamp", l.timestamp); j.writeString("header", l.header); j.writeString("message", l.msg); - j.writeInt("level", l.level); + j.writeInt("level", (int)l.level); j.writeString("channel", l.log); j.end(); return j.str(); diff --git a/Core/Debugger/WebSocket/WebSocketUtils.h b/Core/Debugger/WebSocket/WebSocketUtils.h index c5cbb32c884f..3a4e5fc263e2 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.h +++ b/Core/Debugger/WebSocket/WebSocketUtils.h @@ -42,7 +42,7 @@ struct WebSocketClientInfo { }; struct DebuggerErrorEvent { - DebuggerErrorEvent(const std::string m, LogTypes::LOG_LEVELS l, const JsonGet data = JsonValue(JSON_NULL)) + DebuggerErrorEvent(const std::string m, LogLevel l, const JsonGet data = JsonValue(JSON_NULL)) : message(m), level(l) { // Need to format right away, before it's out of scope. if (data) { @@ -53,7 +53,7 @@ struct DebuggerErrorEvent { } std::string message; - LogTypes::LOG_LEVELS level; + LogLevel level; std::string ticketRaw; operator std::string() const { @@ -61,7 +61,7 @@ struct DebuggerErrorEvent { j.begin(); j.writeString("event", "error"); j.writeString("message", message); - j.writeInt("level", level); + j.writeInt("level", (int)level); if (!ticketRaw.empty()) { j.writeRaw("ticket", ticketRaw); } @@ -88,7 +88,7 @@ struct DebuggerRequest { WebSocketClientInfo *client; void Fail(const std::string &message) { - ws->Send(DebuggerErrorEvent(message, LogTypes::LERROR, data)); + ws->Send(DebuggerErrorEvent(message, LogLevel::LERROR, data)); responseSent_ = true; } diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 42684a0fc2c4..df73ad544d1d 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -813,7 +813,7 @@ bool VirtualDiscFileSystem::RemoveFile(const std::string &filename) return false; } -void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogTypes::LOG_LEVELS level, const char *msg) { +void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogLevel level, const char *msg) { VirtualDiscFileSystem *sys = static_cast(arg); // TODO: Probably could do this smarter / use a lookup. @@ -826,9 +826,9 @@ void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogTy } if (filename != NULL) { - GENERIC_LOG(LogTypes::FILESYS, level, "%s: %s", filename, msg); + GENERIC_LOG(LogType::FILESYS, level, "%s: %s", filename, msg); } else { - GENERIC_LOG(LogTypes::FILESYS, level, "%s", msg); + GENERIC_LOG(LogType::FILESYS, level, "%s", msg); } } diff --git a/Core/FileSystems/VirtualDiscFileSystem.h b/Core/FileSystems/VirtualDiscFileSystem.h index eb3ef16e8bc1..409858817009 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.h +++ b/Core/FileSystems/VirtualDiscFileSystem.h @@ -64,9 +64,9 @@ class VirtualDiscFileSystem: public IFileSystem { typedef void *HandlerLibrary; typedef int HandlerHandle; typedef s64 HandlerOffset; - typedef void (*HandlerLogFunc)(void *arg, HandlerHandle handle, LogTypes::LOG_LEVELS level, const char *msg); + typedef void (*HandlerLogFunc)(void *arg, HandlerHandle handle, LogLevel level, const char *msg); - static void HandlerLogger(void *arg, HandlerHandle handle, LogTypes::LOG_LEVELS level, const char *msg); + static void HandlerLogger(void *arg, HandlerHandle handle, LogLevel level, const char *msg); // The primary purpose of handlers is to make it easier to work with large archives. // However, they have other uses as well, such as patching individual files. diff --git a/Core/HLE/HLE.cpp b/Core/HLE/HLE.cpp index 363a809476ab..5fd835d1bee8 100644 --- a/Core/HLE/HLE.cpp +++ b/Core/HLE/HLE.cpp @@ -853,7 +853,7 @@ size_t hleFormatLogArgs(char *message, size_t sz, const char *argmask) { return used; } -void hleDoLogInternal(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, u64 res, const char *file, int line, const char *reportTag, char retmask, const char *reason, const char *formatted_reason) { +void hleDoLogInternal(LogType t, LogLevel level, u64 res, const char *file, int line, const char *reportTag, char retmask, const char *reason, const char *formatted_reason) { char formatted_args[4096]; const char *funcName = "?"; u32 funcFlags = 0; diff --git a/Core/HLE/HLE.h b/Core/HLE/HLE.h index 0ddba13b6f61..b11efca78e36 100644 --- a/Core/HLE/HLE.h +++ b/Core/HLE/HLE.h @@ -155,11 +155,11 @@ const HLEFunction *GetSyscallFuncPointer(MIPSOpcode op); // For jit, takes arg: const HLEFunction * void *GetQuickSyscallFunc(MIPSOpcode op); -void hleDoLogInternal(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, u64 res, const char *file, int line, const char *reportTag, char retmask, const char *reason, const char *formatted_reason); +void hleDoLogInternal(LogType t, LogLevel level, u64 res, const char *file, int line, const char *reportTag, char retmask, const char *reason, const char *formatted_reason); template -T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char *file, int line, const char *reportTag, char retmask, const char *reason, ...) { - if (level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) { +T hleDoLog(LogType t, LogLevel level, T res, const char *file, int line, const char *reportTag, char retmask, const char *reason, ...) { + if ((int)level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) { return res; } @@ -186,8 +186,8 @@ T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char * } template -T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char *file, int line, const char *reportTag, char retmask) { - if ((level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) && !reportTag) { +T hleDoLog(LogType t, LogLevel level, T res, const char *file, int line, const char *reportTag, char retmask) { + if (((int)level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) && !reportTag) { return res; } @@ -216,7 +216,7 @@ T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char * #define HLE_LOG_LVERBOSE LVERBOSE #endif -#define hleLogHelper(t, level, res, retmask, ...) hleDoLog(LogTypes::t, LogTypes::level, res, __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__) +#define hleLogHelper(t, level, res, retmask, ...) hleDoLog(LogType::t, LogLevel::level, res, __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__) #define hleLogError(t, res, ...) hleLogHelper(t, LERROR, res, 'x', ##__VA_ARGS__) #define hleLogWarning(t, res, ...) hleLogHelper(t, LWARNING, res, 'x', ##__VA_ARGS__) #define hleLogDebug(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__) @@ -228,7 +228,7 @@ T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char * #define hleLogSuccessVerboseX(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__) #define hleLogSuccessVerboseI(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'i', ##__VA_ARGS__) -#define hleReportError(t, res, ...) hleDoLog(LogTypes::t, LogTypes::LERROR, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) -#define hleReportWarning(t, res, ...) hleDoLog(LogTypes::t, LogTypes::LWARNING, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) -#define hleReportDebug(t, res, ...) hleDoLog(LogTypes::t, LogTypes::HLE_LOG_LDEBUG, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) -#define hleReportVerbose(t, res, ...) hleDoLog(LogTypes::t, LogTypes::HLE_LOG_LVERBOSE, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) +#define hleReportError(t, res, ...) hleDoLog(LogType::t, LogLevel::LERROR, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) +#define hleReportWarning(t, res, ...) hleDoLog(LogType::t, LogLevel::LWARNING, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) +#define hleReportDebug(t, res, ...) hleDoLog(LogType::t, LogLevel::HLE_LOG_LDEBUG, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) +#define hleReportVerbose(t, res, ...) hleDoLog(LogType::t, LogLevel::HLE_LOG_LVERBOSE, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__) diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 14a026dc47ab..10d1e3ea19a0 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -224,12 +224,12 @@ void LogScreen::UpdateLog() { TextView *v = vert_->Add(new TextView(ring->TextAt(i), FLAG_DYNAMIC_ASCII, false)); uint32_t color = 0xFFFFFF; switch (ring->LevelAt(i)) { - case LogTypes::LDEBUG: color = 0xE0E0E0; break; - case LogTypes::LWARNING: color = 0x50FFFF; break; - case LogTypes::LERROR: color = 0x5050FF; break; - case LogTypes::LNOTICE: color = 0x30FF30; break; - case LogTypes::LINFO: color = 0xFFFFFF; break; - case LogTypes::LVERBOSE: color = 0xC0C0C0; break; + case LogLevel::LDEBUG: color = 0xE0E0E0; break; + case LogLevel::LWARNING: color = 0x50FFFF; break; + case LogLevel::LERROR: color = 0x5050FF; break; + case LogLevel::LNOTICE: color = 0x30FF30; break; + case LogLevel::LINFO: color = 0xFFFFFF; break; + case LogLevel::LVERBOSE: color = 0xC0C0C0; break; } v->SetTextColor(0xFF000000 | color); } @@ -308,7 +308,7 @@ void LogConfigScreen::CreateViews() { GridLayout *grid = vert->Add(new GridLayoutList(gridsettings, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); for (int i = 0; i < LogManager::GetNumChannels(); i++) { - LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; + LogType type = (LogType)i; LogChannel *chan = logMan->GetLogChannel(type); LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(cellSize - 50, WRAP_CONTENT)); row->SetSpacing(0); @@ -321,7 +321,7 @@ void LogConfigScreen::CreateViews() { UI::EventReturn LogConfigScreen::OnToggleAll(UI::EventParams &e) { LogManager *logMan = LogManager::GetInstance(); for (int i = 0; i < LogManager::GetNumChannels(); i++) { - LogChannel *chan = logMan->GetLogChannel((LogTypes::LOG_TYPE)i); + LogChannel *chan = logMan->GetLogChannel((LogType)i); chan->enabled = !chan->enabled; } return UI::EVENT_DONE; @@ -330,7 +330,7 @@ UI::EventReturn LogConfigScreen::OnToggleAll(UI::EventParams &e) { UI::EventReturn LogConfigScreen::OnEnableAll(UI::EventParams &e) { LogManager *logMan = LogManager::GetInstance(); for (int i = 0; i < LogManager::GetNumChannels(); i++) { - LogChannel *chan = logMan->GetLogChannel((LogTypes::LOG_TYPE)i); + LogChannel *chan = logMan->GetLogChannel((LogType)i); chan->enabled = true; } return UI::EVENT_DONE; @@ -339,7 +339,7 @@ UI::EventReturn LogConfigScreen::OnEnableAll(UI::EventParams &e) { UI::EventReturn LogConfigScreen::OnDisableAll(UI::EventParams &e) { LogManager *logMan = LogManager::GetInstance(); for (int i = 0; i < LogManager::GetNumChannels(); i++) { - LogChannel *chan = logMan->GetLogChannel((LogTypes::LOG_TYPE)i); + LogChannel *chan = logMan->GetLogChannel((LogType)i); chan->enabled = false; } return UI::EVENT_DONE; @@ -377,10 +377,10 @@ void LogLevelScreen::OnCompleted(DialogResult result) { LogManager *logMan = LogManager::GetInstance(); for (int i = 0; i < LogManager::GetNumChannels(); ++i) { - LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; + LogType type = (LogType)i; LogChannel *chan = logMan->GetLogChannel(type); if (chan->enabled) - chan->level = (LogTypes::LOG_LEVELS)(selected + 1); + chan->level = (LogLevel)(selected + 1); } } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 1eaeb1ebeedb..033d92bcd838 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -188,18 +188,18 @@ class PrintfLogger : public LogListener { void Log(const LogMessage &message) override { // Log with simplified headers as Android already provides timestamp etc. switch (message.level) { - case LogTypes::LVERBOSE: - case LogTypes::LDEBUG: - case LogTypes::LINFO: + case LogLevel::LVERBOSE: + case LogLevel::LDEBUG: + case LogLevel::LINFO: printf("INFO [%s] %s", message.log, message.msg.c_str()); break; - case LogTypes::LERROR: + case LogLevel::LERROR: printf("ERR [%s] %s", message.log, message.msg.c_str()); break; - case LogTypes::LWARNING: + case LogLevel::LWARNING: printf("WARN [%s] %s", message.log, message.msg.c_str()); break; - case LogTypes::LNOTICE: + case LogLevel::LNOTICE: default: printf("NOTE [%s] !!! %s", message.log, message.msg.c_str()); break; @@ -567,9 +567,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch boot_filename.clear(); // Parse command line - LogTypes::LOG_LEVELS logLevel = LogTypes::LINFO; + LogLevel logLevel = LogLevel::LINFO; bool forceLogLevel = false; - const auto setLogLevel = [&logLevel, &forceLogLevel](LogTypes::LOG_LEVELS level) { + const auto setLogLevel = [&logLevel, &forceLogLevel](LogLevel level) { logLevel = level; forceLogLevel = true; }; @@ -587,12 +587,12 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch case 'd': // Enable debug logging // Note that you must also change the max log level in Log.h. - setLogLevel(LogTypes::LDEBUG); + setLogLevel(LogLevel::LDEBUG); break; case 'v': // Enable verbose logging // Note that you must also change the max log level in Log.h. - setLogLevel(LogTypes::LVERBOSE); + setLogLevel(LogLevel::LVERBOSE); break; case 'j': g_Config.iCpuCore = (int)CPUCore::JIT; @@ -612,7 +612,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch break; case '-': if (!strncmp(argv[i], "--loglevel=", strlen("--loglevel=")) && strlen(argv[i]) > strlen("--loglevel=")) - setLogLevel(static_cast(std::atoi(argv[i] + strlen("--loglevel=")))); + setLogLevel(static_cast(std::atoi(argv[i] + strlen("--loglevel=")))); if (!strncmp(argv[i], "--log=", strlen("--log=")) && strlen(argv[i]) > strlen("--log=")) fileToLog = argv[i] + strlen("--log="); if (!strncmp(argv[i], "--state=", strlen("--state=")) && strlen(argv[i]) > strlen("--state=")) diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 5344e672f908..2a137e08ba61 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -127,7 +127,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptrSetAllLogLevels(LogTypes::LDEBUG); + LogManager::GetInstance()->SetAllLogLevels(LogLevel::LDEBUG); } // Set log file location diff --git a/Windows/main.cpp b/Windows/main.cpp index 39d6b7f838f9..0e3937fcd80d 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -972,7 +972,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin LogManager::GetInstance()->GetConsoleListener()->Init(showLog, 150, 120, "PPSSPP Debug Console"); if (debugLogLevel) { - LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG); + LogManager::GetInstance()->SetAllLogLevels(LogLevel::LDEBUG); } // This still seems to improve performance noticeably. diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 66cfc5933de2..9906b6fa8f5c 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -202,10 +202,10 @@ int utimensat(int fd, const char *path, const struct timespec times[2]) { void AndroidLogger::Log(const LogMessage &message) { int mode; switch (message.level) { - case LogTypes::LWARNING: + case LogLevel::LWARNING: mode = ANDROID_LOG_WARN; break; - case LogTypes::LERROR: + case LogLevel::LERROR: mode = ANDROID_LOG_ERROR; break; default: diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 9ebe83d2b05e..16c7991bf35d 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -70,22 +70,22 @@ class PrintfLogger : public LogListener { public: void Log(const LogMessage &message) override { switch (message.level) { - case LogTypes::LVERBOSE: + case LogLevel::LVERBOSE: fprintf(stderr, "V %s", message.msg.c_str()); break; - case LogTypes::LDEBUG: + case LogLevel::LDEBUG: fprintf(stderr, "D %s", message.msg.c_str()); break; - case LogTypes::LINFO: + case LogLevel::LINFO: fprintf(stderr, "I %s", message.msg.c_str()); break; - case LogTypes::LERROR: + case LogLevel::LERROR: fprintf(stderr, "E %s", message.msg.c_str()); break; - case LogTypes::LWARNING: + case LogLevel::LWARNING: fprintf(stderr, "W %s", message.msg.c_str()); break; - case LogTypes::LNOTICE: + case LogLevel::LNOTICE: default: fprintf(stderr, "N %s", message.msg.c_str()); break; @@ -428,10 +428,10 @@ int main(int argc, const char* argv[]) PrintfLogger *printfLogger = new PrintfLogger(); - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { - LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; + for (int i = 0; i < (int)LogType::NUMBER_OF_LOGS; i++) { + LogType type = (LogType)i; logman->SetEnabled(type, fullLog); - logman->SetLogLevel(type, LogTypes::LDEBUG); + logman->SetLogLevel(type, LogLevel::LDEBUG); } logman->AddListener(printfLogger); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 5f0764930b34..2c4ebdc34dc6 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -239,22 +239,22 @@ class PrintfLogger : public LogListener { switch (message.level) { - case LogTypes::LVERBOSE: - case LogTypes::LDEBUG: + case LogLevel::LVERBOSE: + case LogLevel::LDEBUG: log_(RETRO_LOG_DEBUG, "[%s] %s", message.log, message.msg.c_str()); break; - case LogTypes::LERROR: + case LogLevel::LERROR: log_(RETRO_LOG_ERROR, "[%s] %s", message.log, message.msg.c_str()); break; - case LogTypes::LNOTICE: - case LogTypes::LWARNING: + case LogLevel::LNOTICE: + case LogLevel::LWARNING: log_(RETRO_LOG_WARN, "[%s] %s", message.log, message.msg.c_str()); break; - case LogTypes::LINFO: + case LogLevel::LINFO: default: log_(RETRO_LOG_INFO, "[%s] %s", message.log, message.msg.c_str()); @@ -1081,7 +1081,7 @@ void retro_init(void) logman->RemoveListener(logman->GetDebuggerListener()); logman->ChangeFileLog(nullptr); logman->AddListener(printfLogger); - logman->SetAllLogLevels(LogTypes::LINFO); + logman->SetAllLogLevels(LogLevel::LINFO); } g_Config.Load("", ""); From 0ce5e210597f3f8009eb81abe3ed3754e87fe5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 25 Aug 2023 11:44:09 +0200 Subject: [PATCH 2/3] Minor simplification --- Common/Log.h | 1 + Common/LogManager.cpp | 83 +++++++++++++++++++++---------------------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/Common/Log.h b/Common/Log.h index b272f476c16b..fbbbdaea4e5e 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -26,6 +26,7 @@ #define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. #define VERBOSE_LEVEL 6 // Noisy debugging - sometimes needed but usually unimportant. +// NOTE: Needs to be kept in sync with the g_logTypeNames array. enum class LogType { SYSTEM = 0, // Catch-all for uncategorized things BOOT, diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index d12a253deebb..465bf999aef5 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -77,56 +77,53 @@ bool GenericLogEnabled(LogLevel level, LogType type) { LogManager *LogManager::logManager_ = NULL; -struct LogNameTableEntry { - LogType logType; - const char *name; -}; - -static const LogNameTableEntry logTable[] = { - {LogType::SYSTEM, "SYSTEM"}, - {LogType::BOOT, "BOOT"}, - {LogType::COMMON, "COMMON"}, - {LogType::CPU, "CPU"}, - {LogType::FILESYS, "FILESYS"}, - {LogType::G3D, "G3D"}, - {LogType::HLE, "HLE"}, - {LogType::JIT, "JIT"}, - {LogType::LOADER, "LOADER"}, - {LogType::ME, "ME"}, // Media Engine - {LogType::MEMMAP, "MEMMAP"}, - {LogType::SASMIX, "SASMIX"}, - {LogType::SAVESTATE, "SAVESTATE"}, - {LogType::FRAMEBUF, "FRAMEBUF"}, - {LogType::AUDIO, "AUDIO"}, - {LogType::IO, "IO"}, - - {LogType::SCEAUDIO, "SCEAUDIO"}, - {LogType::SCECTRL, "SCECTRL"}, - {LogType::SCEDISPLAY, "SCEDISP"}, - {LogType::SCEFONT, "SCEFONT"}, - {LogType::SCEGE, "SCEGE"}, - {LogType::SCEINTC, "SCEINTC"}, - {LogType::SCEIO, "SCEIO"}, - {LogType::SCEKERNEL, "SCEKERNEL"}, - {LogType::SCEMODULE, "SCEMODULE"}, - {LogType::SCENET, "SCENET"}, - {LogType::SCERTC, "SCERTC"}, - {LogType::SCESAS, "SCESAS"}, - {LogType::SCEUTILITY, "SCEUTIL"}, - {LogType::SCEMISC, "SCEMISC"}, +// NOTE: Needs to be kept in sync with the LogType enum. +static const char *g_logTypeNames[] = { + "SYSTEM", + "BOOT", + "COMMON", + "CPU", + "FILESYS", + "G3D", + "HLE", + "JIT", + "LOADER", + "ME", // Media Engine + "MEMMAP", + "SASMIX", + "SAVESTATE", + "FRAMEBUF", + "AUDIO", + "IO", + + "SCEAUDIO", + "SCECTRL", + "SCEDISP", + "SCEFONT", + "SCEGE", + "SCEINTC", + "SCEIO", + "SCEKERNEL", + "SCEMODULE", + "SCENET", + "SCERTC", + "SCESAS", + "SCEUTIL", + "SCEMISC", }; LogManager::LogManager(bool *enabledSetting) { g_bLogEnabledSetting = enabledSetting; - for (size_t i = 0; i < ARRAY_SIZE(logTable); i++) { - _assert_msg_((LogType)i == logTable[i].logType, "Bad logtable at %i", (int)i); - truncate_cpy(log_[(size_t)logTable[i].logType].m_shortName, logTable[i].name); - log_[(size_t)logTable[i].logType].enabled = true; + _dbg_assert_(ARRAY_SIZE(g_logTypeNames) == (size_t)LogType::NUMBER_OF_LOGS); + + for (size_t i = 0; i < ARRAY_SIZE(g_logTypeNames); i++) { + truncate_cpy(log_[i].m_shortName, g_logTypeNames[i]); + log_[i].enabled = true; #if defined(_DEBUG) - log_[(size_t)logTable[i].logType].level = LogLevel::LDEBUG; + log_[i].level = LogLevel::LDEBUG; #else - log_[(size_t)logTable[i].logType].level = LogLevel::LINFO; + log_[i].level = LogLevel::LINFO; #endif } From c59e9e51b256a46f661bfdd879111b146f72f172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 25 Aug 2023 12:39:19 +0200 Subject: [PATCH 3/3] Non-change to see if CI fixes itself.. --- Core/MIPS/ARM64/Arm64Jit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/MIPS/ARM64/Arm64Jit.cpp b/Core/MIPS/ARM64/Arm64Jit.cpp index 5a073897d4a1..1b5c4aca69f2 100644 --- a/Core/MIPS/ARM64/Arm64Jit.cpp +++ b/Core/MIPS/ARM64/Arm64Jit.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "ppsspp_config.h" + #if PPSSPP_ARCH(ARM64) #include "Common/Profiler/Profiler.h"