Fix DEBUG logging (didn't work!). Shuffle around the log levels to make more sense (now NOTICE is the top one and always on), the rest is ERROR, WARNING, INFO, DEBUG. Fix the log levels of a lot of stuff. Use macros instead of numbers for various log level checks.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2700 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-03-20 20:52:37 +00:00
parent 554a930fe9
commit aa7fe1edee
23 changed files with 100 additions and 86 deletions

View File

@ -48,7 +48,7 @@ void ConsoleListener::Open(int width, int height, char *title)
SetConsoleTitle(title);
// Set the total letter space
COORD co = {width, height};
COORD co = {width, 3000}; // Big scrollback.
SetConsoleScreenBufferSize(m_hStdOut, co);
/* Set the window size in number of letters. The height is hard coded here
@ -102,7 +102,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text)
break;
case INFO_LEVEL: // cyan
color = FOREGROUND_GREEN | FOREGROUND_BLUE;
color = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
case DEBUG_LEVEL: // light gray

View File

@ -18,9 +18,9 @@
#ifndef _LOG_H
#define _LOG_H
#define ERROR_LEVEL 1 // Critical errors
#define WARNING_LEVEL 2 // Something is suspicious.
#define NOTICE_LEVEL 3 // Important information
#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.
@ -70,9 +70,9 @@ enum LOG_TYPE {
// FIXME: should this be removed?
enum LOG_LEVELS {
LNOTICE = NOTICE_LEVEL,
LERROR = ERROR_LEVEL,
LWARNING = WARNING_LEVEL,
LNOTICE = NOTICE_LEVEL,
LINFO = INFO_LEVEL,
LDEBUG = DEBUG_LEVEL,
};
@ -85,10 +85,10 @@ enum LOG_LEVELS {
- Debug_run() - run only in debug time
*/
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
#define LOGLEVEL DEBUG_LEVEL
#define MAX_LOGLEVEL DEBUG_LEVEL
#else
#ifndef LOGLEVEL
#define LOGLEVEL NOTICE_LEVEL
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL WARNING_LEVEL
#endif // loglevel
#endif // logging
@ -102,33 +102,33 @@ enum LOG_LEVELS {
#include "LogManager.h"
// Let the compiler optimize this out
#define GENERIC_LOG(t, v, ...) {if (v <= LOGLEVEL) LogManager::GetInstance()->Log(v, t, __VA_ARGS__);}
#define GENERIC_LOG(t, v, ...) {if (v <= MAX_LOGLEVEL) {LogManager::GetInstance()->Log(v, t, __VA_ARGS__);}}
#if LOGLEVEL >= ERROR_LEVEL
#if MAX_LOGLEVEL >= ERROR_LEVEL
#undef ERROR_LOG
#define ERROR_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__)}
#endif // loglevel ERROR+
#if LOGLEVEL >= WARNING_LEVEL
#if MAX_LOGLEVEL >= WARNING_LEVEL
#undef WARN_LOG
#define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__)}
#endif // loglevel WARNING+
#if LOGLEVEL >= NOTICE_LEVEL
#if MAX_LOGLEVEL >= NOTICE_LEVEL
#undef NOTICE_LOG
#define NOTICE_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__)}
#endif // loglevel NOTICE+
#if LOGLEVEL >= INFO_LEVEL
#if MAX_LOGLEVEL >= INFO_LEVEL
#undef INFO_LOG
#define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__)}
#endif // loglevel INFO+
#if LOGLEVEL >= DEBUG_LEVEL
#if MAX_LOGLEVEL >= DEBUG_LEVEL
#undef DEBUG_LOG
#define DEBUG_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__)}
#endif // loglevel DEBUG+
#if LOGLEVEL >= DEBUG_LEVEL
#if MAX_LOGLEVEL >= DEBUG_LEVEL
#define _dbg_assert_(_t_, _a_) \
if (!(_a_)) {\
ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
@ -150,7 +150,7 @@ enum LOG_LEVELS {
#define _dbg_assert_(_t_, _a_) ;
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) ;
#endif // dbg_assert
#endif // LOGLEVEL DEBUG
#endif // MAX_LOGLEVEL DEBUG
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
#ifdef _WIN32

View File

@ -97,6 +97,13 @@ void LogManager::removeListener(LogTypes::LOG_TYPE type, LogListener *listener)
logMutex->Leave();
}
LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
: m_enable(enable) {
strncpy(m_fullName, fullName, 128);
strncpy(m_shortName, shortName, 32);
m_level = LogTypes::LWARNING;
}
// LogContainer
void LogContainer::addListener(LogListener *listener) {
bool exists = false;

View File

@ -90,12 +90,7 @@ private:
class LogContainer {
public:
LogContainer(const char* shortName, const char* fullName,
bool enable = false) : m_enable(enable) {
strncpy(m_fullName, fullName, 128);
strncpy(m_shortName, shortName, 32);
m_level = LogTypes::LWARNING;
}
LogContainer(const char* shortName, const char* fullName, bool enable = false);
const char *getShortName() const { return m_shortName; }
const char *getFullName() const { return m_fullName; }
@ -111,7 +106,7 @@ public:
m_enable = enable;
}
LogTypes::LOG_LEVELS getLevel() {
LogTypes::LOG_LEVELS getLevel() const {
return m_level;
}
@ -138,7 +133,7 @@ private:
static LogManager *m_logManager; // Singleton. Ugh.
public:
static u32 GetMaxLevel() { return LOGLEVEL; }
static u32 GetMaxLevel() { return MAX_LOGLEVEL; }
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *fmt, ...);