Common: Kill off duplicate log warning definitions

Also embed the log checks rather than using macros
This commit is contained in:
Lioncash 2014-08-21 20:11:52 -04:00
parent 48f52b9662
commit 690ed8580c
6 changed files with 53 additions and 57 deletions

View File

@ -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:

View File

@ -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

View File

@ -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);
}
}
};

View File

@ -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)
{

View File

@ -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);

View File

@ -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;