2009-03-07 08:35:01 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-03-28 08:57:34 +00:00
|
|
|
#ifndef _LOG_H_
|
|
|
|
#define _LOG_H_
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-20 20:52:37 +00:00
|
|
|
#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.
|
2009-03-18 17:17:58 +00:00
|
|
|
#define INFO_LEVEL 4 // General information.
|
|
|
|
#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow.
|
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
namespace LogTypes
|
|
|
|
{
|
|
|
|
|
|
|
|
enum LOG_TYPE {
|
|
|
|
ACTIONREPLAY,
|
|
|
|
AUDIO,
|
|
|
|
AUDIO_INTERFACE,
|
|
|
|
BOOT,
|
|
|
|
COMMANDPROCESSOR,
|
|
|
|
COMMON,
|
|
|
|
CONSOLE,
|
|
|
|
DISCIO,
|
|
|
|
DSPHLE,
|
2009-04-06 17:12:05 +00:00
|
|
|
DSPLLE,
|
2009-03-07 08:35:01 +00:00
|
|
|
DSPINTERFACE,
|
|
|
|
DVDINTERFACE,
|
|
|
|
DYNA_REC,
|
|
|
|
EXPANSIONINTERFACE,
|
2009-05-01 15:17:03 +00:00
|
|
|
POWERPC,
|
2009-03-07 08:35:01 +00:00
|
|
|
GPFIFO,
|
|
|
|
HLE,
|
|
|
|
MASTER_LOG,
|
|
|
|
MEMMAP,
|
|
|
|
OSREPORT,
|
2009-03-18 17:17:58 +00:00
|
|
|
PAD,
|
2009-03-07 08:35:01 +00:00
|
|
|
PERIPHERALINTERFACE,
|
|
|
|
PIXELENGINE,
|
|
|
|
SERIALINTERFACE,
|
2009-05-04 19:28:53 +00:00
|
|
|
SP1,
|
2009-03-07 08:35:01 +00:00
|
|
|
STREAMINGINTERFACE,
|
|
|
|
VIDEO,
|
|
|
|
VIDEOINTERFACE,
|
|
|
|
WII_IOB,
|
|
|
|
WII_IPC,
|
|
|
|
WII_IPC_DVD,
|
|
|
|
WII_IPC_ES,
|
|
|
|
WII_IPC_FILEIO,
|
|
|
|
WII_IPC_HLE,
|
|
|
|
WII_IPC_NET,
|
|
|
|
WII_IPC_SD,
|
2009-04-19 17:03:48 +00:00
|
|
|
WII_IPC_STM,
|
2009-03-07 08:35:01 +00:00
|
|
|
WII_IPC_WIIMOTE,
|
2009-03-18 17:17:58 +00:00
|
|
|
WIIMOTE,
|
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
NUMBER_OF_LOGS // Must be last
|
|
|
|
};
|
|
|
|
|
2009-03-18 17:17:58 +00:00
|
|
|
// FIXME: should this be removed?
|
2009-03-07 08:35:01 +00:00
|
|
|
enum LOG_LEVELS {
|
2009-03-20 20:52:37 +00:00
|
|
|
LNOTICE = NOTICE_LEVEL,
|
2009-03-18 17:17:58 +00:00
|
|
|
LERROR = ERROR_LEVEL,
|
|
|
|
LWARNING = WARNING_LEVEL,
|
|
|
|
LINFO = INFO_LEVEL,
|
|
|
|
LDEBUG = DEBUG_LEVEL,
|
2009-03-07 08:35:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
FIXME:
|
|
|
|
- Debug_run() - run only in debug time
|
|
|
|
*/
|
2009-03-18 17:17:58 +00:00
|
|
|
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
|
2009-03-20 20:52:37 +00:00
|
|
|
#define MAX_LOGLEVEL DEBUG_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#else
|
2009-03-20 20:52:37 +00:00
|
|
|
#ifndef MAX_LOGLEVEL
|
|
|
|
#define MAX_LOGLEVEL WARNING_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#endif // loglevel
|
|
|
|
#endif // logging
|
|
|
|
|
|
|
|
#define ERROR_LOG(...) {}
|
|
|
|
#define WARN_LOG(...) {}
|
2009-03-18 17:17:58 +00:00
|
|
|
#define NOTICE_LOG(...) {}
|
2009-03-07 08:35:01 +00:00
|
|
|
#define INFO_LOG(...) {}
|
|
|
|
#define DEBUG_LOG(...) {}
|
|
|
|
|
2009-03-18 17:17:58 +00:00
|
|
|
// FIXME can we get rid of this?
|
|
|
|
#include "LogManager.h"
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-05-03 11:15:17 +00:00
|
|
|
#ifdef GEKKO
|
|
|
|
#define GENERIC_LOG(t, v, ...)
|
|
|
|
#else
|
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
// Let the compiler optimize this out
|
2009-03-20 20:52:37 +00:00
|
|
|
#define GENERIC_LOG(t, v, ...) {if (v <= MAX_LOGLEVEL) {LogManager::GetInstance()->Log(v, t, __VA_ARGS__);}}
|
2009-05-03 11:15:17 +00:00
|
|
|
#endif
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-20 20:52:37 +00:00
|
|
|
#if MAX_LOGLEVEL >= ERROR_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#undef ERROR_LOG
|
|
|
|
#define ERROR_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__)}
|
2009-03-18 17:17:58 +00:00
|
|
|
#endif // loglevel ERROR+
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-20 20:52:37 +00:00
|
|
|
#if MAX_LOGLEVEL >= WARNING_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#undef WARN_LOG
|
|
|
|
#define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__)}
|
2009-03-18 17:17:58 +00:00
|
|
|
#endif // loglevel WARNING+
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-20 20:52:37 +00:00
|
|
|
#if MAX_LOGLEVEL >= NOTICE_LEVEL
|
2009-03-18 17:17:58 +00:00
|
|
|
#undef NOTICE_LOG
|
|
|
|
#define NOTICE_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__)}
|
|
|
|
#endif // loglevel NOTICE+
|
2009-03-20 20:52:37 +00:00
|
|
|
#if MAX_LOGLEVEL >= INFO_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#undef INFO_LOG
|
|
|
|
#define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__)}
|
2009-03-18 17:17:58 +00:00
|
|
|
#endif // loglevel INFO+
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-20 20:52:37 +00:00
|
|
|
#if MAX_LOGLEVEL >= DEBUG_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#undef DEBUG_LOG
|
|
|
|
#define DEBUG_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__)}
|
2009-03-18 17:17:58 +00:00
|
|
|
#endif // loglevel DEBUG+
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-20 20:52:37 +00:00
|
|
|
#if MAX_LOGLEVEL >= DEBUG_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#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?", \
|
|
|
|
__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();} \
|
|
|
|
}
|
|
|
|
#define _dbg_update_() Host_UpdateLogDisplay();
|
|
|
|
|
|
|
|
#else // not debug
|
|
|
|
#define _dbg_clear_()
|
|
|
|
#define _dbg_update_() ;
|
|
|
|
|
|
|
|
#ifndef _dbg_assert_
|
|
|
|
#define _dbg_assert_(_t_, _a_) ;
|
|
|
|
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) ;
|
|
|
|
#endif // dbg_assert
|
2009-03-20 20:52:37 +00:00
|
|
|
#endif // MAX_LOGLEVEL DEBUG
|
2009-03-07 08:35:01 +00:00
|
|
|
|
|
|
|
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
2009-05-03 11:15:17 +00:00
|
|
|
|
|
|
|
#ifndef GEKKO
|
2009-03-07 08:35:01 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
|
|
|
if (!(_a_)) {\
|
|
|
|
if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
|
|
|
#else // not win32
|
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
|
|
|
if (!(_a_)) {\
|
|
|
|
if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
|
|
|
#endif // WIN32
|
2009-05-03 11:15:17 +00:00
|
|
|
#else // GEKKO
|
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...)
|
|
|
|
#endif
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-28 08:57:34 +00:00
|
|
|
#endif // _LOG_H_
|