Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #851 from lioncash/logg
Common: Kill off duplicate log warning definitions
  • Loading branch information
shuffle2 committed Sep 6, 2014
2 parents 85fd8c2 + 01b90c1 commit 9302218
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 292 deletions.
473 changes: 238 additions & 235 deletions Source/Core/Common/ArmEmitter.cpp

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Source/Core/Common/Logging/ConsoleListener.cpp
Expand Up @@ -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
Expand All @@ -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:
Expand Down
61 changes: 31 additions & 30 deletions Source/Core/Common/Logging/Log.h
Expand Up @@ -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
{

Expand Down Expand Up @@ -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";
Expand All @@ -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

Expand All @@ -110,37 +103,45 @@ 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_)

#ifndef GEKKO
#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
Expand Down
5 changes: 2 additions & 3 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h
Expand Up @@ -209,9 +209,8 @@ class IWII_IPC_HLE_Device
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);
}
}
};
Expand Down
11 changes: 5 additions & 6 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
Expand Up @@ -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)
{
Expand Down
7 changes: 2 additions & 5 deletions Source/Core/DiscIO/WiiWad.cpp
Expand Up @@ -101,11 +101,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);
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/DolphinWX/LogWindow.cpp
Expand Up @@ -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;

Expand Down

0 comments on commit 9302218

Please sign in to comment.