diff --git a/Source/Core/Common/Logging/ConsoleListener.cpp b/Source/Core/Common/Logging/ConsoleListener.cpp index 0b3a212126..bdf87bc722 100644 --- a/Source/Core/Common/Logging/ConsoleListener.cpp +++ b/Source/Core/Common/Logging/ConsoleListener.cpp @@ -257,19 +257,19 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text) switch (Level) { - case NOTICE_LEVEL: // light green + case LogTypes::LOG_LEVELS::LNOTICE: // light green Color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; - case ERROR_LEVEL: // light red + case LogTypes::LOG_LEVELS::LERROR: // light red Color = FOREGROUND_RED | FOREGROUND_INTENSITY; break; - case WARNING_LEVEL: // light yellow + case LogTypes::LOG_LEVELS::LWARNING: // light yellow Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; - case INFO_LEVEL: // cyan + case LogTypes::LOG_LEVELS::LINFO: // cyan Color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break; - case DEBUG_LEVEL: // gray + case LogTypes::LOG_LEVELS::LDEBUG: // gray Color = FOREGROUND_INTENSITY; break; default: // off-white @@ -294,13 +294,13 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text) strcpy(ResetAttr, "\033[0m"); switch (Level) { - case NOTICE_LEVEL: // light green + case LogTypes::LOG_LEVELS::LNOTICE: // light green strcpy(ColorAttr, "\033[92m"); break; - case ERROR_LEVEL: // light red + case LogTypes::LOG_LEVELS::LERROR: // light red strcpy(ColorAttr, "\033[91m"); break; - case WARNING_LEVEL: // light yellow + case LogTypes::LOG_LEVELS::LWARNING: // light yellow strcpy(ColorAttr, "\033[93m"); break; default: diff --git a/Source/Core/Common/Logging/Log.h b/Source/Core/Common/Logging/Log.h index c7675a9a07..eeba27d9d0 100644 --- a/Source/Core/Common/Logging/Log.h +++ b/Source/Core/Common/Logging/Log.h @@ -4,12 +4,6 @@ #pragma once -#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and OSReports. -#define ERROR_LEVEL 2 // Critical errors -#define WARNING_LEVEL 3 // Something is suspicious. -#define INFO_LEVEL 4 // General information. -#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. - namespace LogTypes { @@ -65,14 +59,13 @@ enum LOG_TYPE NUMBER_OF_LOGS // Must be last }; -// FIXME: should this be removed? enum LOG_LEVELS { - LNOTICE = NOTICE_LEVEL, - LERROR = ERROR_LEVEL, - LWARNING = WARNING_LEVEL, - LINFO = INFO_LEVEL, - LDEBUG = DEBUG_LEVEL, + LNOTICE = 1, // VERY important information that is NOT errors. Like startup and OSReports. + LERROR = 2, // Critical errors + LWARNING = 3, // Something is suspicious. + LINFO = 4, // General information. + LDEBUG = 5, // Detailed debugging - might make things slow. }; static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID"; @@ -87,10 +80,10 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, ; #if defined LOGGING || defined _DEBUG || defined DEBUGFAST -#define MAX_LOGLEVEL DEBUG_LEVEL +#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LDEBUG #else #ifndef MAX_LOGLEVEL -#define MAX_LOGLEVEL WARNING_LEVEL +#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LWARNING #endif // loglevel #endif // logging @@ -110,24 +103,30 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, #define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0) #define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0) -#if MAX_LOGLEVEL >= DEBUG_LEVEL #define _dbg_assert_(_t_, _a_) \ - if (!(_a_)) {\ + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) {\ ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ - __LINE__, __FILE__, __TIME__); \ - if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \ + __LINE__, __FILE__, __TIME__); \ + if (!PanicYesNo("*** Assertion (see log)***\n")) \ + Crash(); \ } -#define _dbg_assert_msg_(_t_, _a_, ...)\ - if (!(_a_)) {\ - ERROR_LOG(_t_, __VA_ARGS__); \ - if (!PanicYesNo(__VA_ARGS__)) {Crash();} \ + +#ifdef _WIN32 +#define _dbg_assert_msg_(_t_, _a_, _msg_, ...)\ + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) {\ + ERROR_LOG(_t_, _msg_, __VA_ARGS__); \ + if (!PanicYesNo(_msg_, __VA_ARGS__)) \ + Crash(); \ } -#else // not debug -#ifndef _dbg_assert_ -#define _dbg_assert_(_t_, _a_) {} -#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {} -#endif // dbg_assert -#endif // MAX_LOGLEVEL DEBUG +#else +#define _dbg_assert_msg_(_t_, _a_, _msg_, ...)\ + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) {\ + ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \ + if (!PanicYesNo(_msg_, ##__VA_ARGS__)) \ + Crash(); \ + } +#endif + #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) @@ -135,12 +134,14 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, #ifdef _WIN32 #define _assert_msg_(_t_, _a_, _fmt_, ...) \ if (!(_a_)) {\ - if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \ + if (!PanicYesNo(_fmt_, __VA_ARGS__)) \ + Crash(); \ } #else // not win32 #define _assert_msg_(_t_, _a_, _fmt_, ...) \ if (!(_a_)) {\ - if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ + if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \ + Crash(); \ } #endif // WIN32 #else // GEKKO diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h index 26f8224375..86b268853d 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h @@ -209,9 +209,8 @@ protected: GENERIC_LOG(LogType, LogTypes::LINFO, " OutBuffer: 0x%08x (0x%x):", OutBuffer, OutBufferSize); - #if defined(MAX_LOGLEVEL) && MAX_LOGLEVEL >= INFO_LEVEL - DumpCommands(OutBuffer, OutBufferSize, LogType, Verbosity); - #endif + if (Verbosity >= LogTypes::LOG_LEVELS::LINFO) + DumpCommands(OutBuffer, OutBufferSize, LogType, Verbosity); } } }; diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index 52edbec328..c1e95c6a6a 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -710,12 +710,11 @@ static int ParseAttribList(u8* pAttribIDList, u16& _startID, u16& _endID) u8 seqSize = attribList.Read8(attribOffset); attribOffset++; u8 typeID = attribList.Read8(attribOffset); attribOffset++; -#if MAX_LOGLEVEL >= DEBUG_LEVEL - _dbg_assert_(WII_IPC_WIIMOTE, sequence == SDP_SEQ8); - (void)seqSize; -#else - (void)sequence, (void)seqSize; -#endif + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) + { + _dbg_assert_(WII_IPC_WIIMOTE, sequence == SDP_SEQ8); + (void)seqSize; + } if (typeID == SDP_UINT32) { diff --git a/Source/Core/DiscIO/WiiWad.cpp b/Source/Core/DiscIO/WiiWad.cpp index 341cadfcca..2b8703b5bd 100644 --- a/Source/Core/DiscIO/WiiWad.cpp +++ b/Source/Core/DiscIO/WiiWad.cpp @@ -102,11 +102,8 @@ bool WiiWAD::ParseWAD(DiscIO::IBlobReader& _rReader) m_DataAppSize = ReaderBig.Read32(0x18); m_FooterSize = ReaderBig.Read32(0x1C); -#if MAX_LOGLEVEL >= DEBUG_LEVEL - _dbg_assert_msg_(BOOT, Reserved==0x00, "WiiWAD: Reserved must be 0x00"); -#else - (void)Reserved; -#endif + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) + _dbg_assert_msg_(BOOT, Reserved==0x00, "WiiWAD: Reserved must be 0x00"); u32 Offset = 0x40; m_pCertificateChain = CreateWADEntry(_rReader, m_CertificateChainSize, Offset); Offset += ROUND_UP(m_CertificateChainSize, 0x40); diff --git a/Source/Core/DolphinWX/LogWindow.cpp b/Source/Core/DolphinWX/LogWindow.cpp index a28d455b1e..24a0aef2a9 100644 --- a/Source/Core/DolphinWX/LogWindow.cpp +++ b/Source/Core/DolphinWX/LogWindow.cpp @@ -314,23 +314,23 @@ void CLogWindow::UpdateLog() { switch (msgQueue.front().first) { - case ERROR_LEVEL: + case LogTypes::LOG_LEVELS::LERROR: m_Log->SetDefaultStyle(wxTextAttr(*wxRED)); break; - case WARNING_LEVEL: + case LogTypes::LOG_LEVELS::LWARNING: m_Log->SetDefaultStyle(wxTextAttr(*wxYELLOW)); break; - case NOTICE_LEVEL: + case LogTypes::LOG_LEVELS::LNOTICE: m_Log->SetDefaultStyle(wxTextAttr(*wxGREEN)); break; - case INFO_LEVEL: + case LogTypes::LOG_LEVELS::LINFO: m_Log->SetDefaultStyle(wxTextAttr(*wxCYAN)); break; - case DEBUG_LEVEL: + case LogTypes::LOG_LEVELS::LDEBUG: m_Log->SetDefaultStyle(wxTextAttr(*wxLIGHT_GREY)); break;