2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-28 08:57:34 +00:00
|
|
|
#ifndef _LOG_H_
|
|
|
|
#define _LOG_H_
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2013-10-19 22:58:02 +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.
|
|
|
|
#define INFO_LEVEL 4 // General information.
|
|
|
|
#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow.
|
2010-12-14 17:52:01 +00:00
|
|
|
|
|
|
|
namespace LogTypes
|
|
|
|
{
|
|
|
|
|
2013-10-19 22:58:02 +00:00
|
|
|
enum LOG_TYPE
|
|
|
|
{
|
2009-03-07 08:35:01 +00:00
|
|
|
ACTIONREPLAY,
|
|
|
|
AUDIO,
|
|
|
|
AUDIO_INTERFACE,
|
|
|
|
BOOT,
|
|
|
|
COMMANDPROCESSOR,
|
|
|
|
COMMON,
|
|
|
|
CONSOLE,
|
|
|
|
DISCIO,
|
2009-09-03 20:00:09 +00:00
|
|
|
FILEMON,
|
2009-03-07 08:35:01 +00:00
|
|
|
DSPHLE,
|
2009-04-06 17:12:05 +00:00
|
|
|
DSPLLE,
|
2009-07-18 01:16:17 +00:00
|
|
|
DSP_MAIL,
|
2009-03-07 08:35:01 +00:00
|
|
|
DSPINTERFACE,
|
|
|
|
DVDINTERFACE,
|
|
|
|
DYNA_REC,
|
|
|
|
EXPANSIONINTERFACE,
|
2013-01-06 10:28:27 +00:00
|
|
|
GDB_STUB,
|
2009-05-01 15:17:03 +00:00
|
|
|
POWERPC,
|
2009-03-07 08:35:01 +00:00
|
|
|
GPFIFO,
|
2010-12-05 15:59:11 +00:00
|
|
|
OSHLE,
|
2009-03-07 08:35:01 +00:00
|
|
|
MASTER_LOG,
|
|
|
|
MEMMAP,
|
2009-07-18 01:16:17 +00:00
|
|
|
MEMCARD_MANAGER,
|
2009-03-07 08:35:01 +00:00
|
|
|
OSREPORT,
|
2009-03-18 17:17:58 +00:00
|
|
|
PAD,
|
2009-10-06 15:49:20 +00:00
|
|
|
PROCESSORINTERFACE,
|
2009-03-07 08:35:01 +00:00
|
|
|
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,
|
2012-03-28 08:52:17 +00:00
|
|
|
WII_IPC_HID,
|
2009-03-07 08:35:01 +00:00
|
|
|
WII_IPC_HLE,
|
|
|
|
WII_IPC_NET,
|
2013-01-04 09:35:48 +00:00
|
|
|
WII_IPC_WC24,
|
|
|
|
WII_IPC_SSL,
|
2009-03-07 08:35:01 +00:00
|
|
|
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-08-15 14:34:52 +00:00
|
|
|
NETPLAY,
|
2009-03-18 17:17:58 +00:00
|
|
|
|
2009-03-07 08:35:01 +00:00
|
|
|
NUMBER_OF_LOGS // Must be last
|
|
|
|
};
|
|
|
|
|
2010-12-14 17:52:01 +00:00
|
|
|
// FIXME: should this be removed?
|
2013-10-19 22:58:02 +00:00
|
|
|
enum LOG_LEVELS
|
|
|
|
{
|
|
|
|
LNOTICE = NOTICE_LEVEL,
|
|
|
|
LERROR = ERROR_LEVEL,
|
2010-12-14 17:52:01 +00:00
|
|
|
LWARNING = WARNING_LEVEL,
|
2013-10-19 22:58:02 +00:00
|
|
|
LINFO = INFO_LEVEL,
|
|
|
|
LDEBUG = DEBUG_LEVEL,
|
2009-03-07 08:35:01 +00:00
|
|
|
};
|
|
|
|
|
2010-12-14 17:52:01 +00:00
|
|
|
#define LOGTYPES_LEVELS LogTypes::LOG_LEVELS
|
|
|
|
#define LOGTYPES_TYPE LogTypes::LOG_TYPE
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type,
|
2010-12-05 09:04:34 +00:00
|
|
|
const char *file, int line, const char *fmt, ...)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__((format(printf, 5, 6)))
|
|
|
|
#endif
|
|
|
|
;
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2009-03-18 17:17:58 +00:00
|
|
|
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
|
2013-01-26 05:22:58 +00:00
|
|
|
#define MAX_LOGLEVEL DEBUG_LEVEL
|
2009-03-07 08:35:01 +00:00
|
|
|
#else
|
2009-09-01 08:44:32 +00:00
|
|
|
#ifndef MAX_LOGLEVEL
|
2013-04-11 12:14:38 +00:00
|
|
|
#define MAX_LOGLEVEL WARNING_LEVEL
|
2009-09-01 08:44:32 +00:00
|
|
|
#endif // loglevel
|
2009-03-07 08:35:01 +00:00
|
|
|
#endif // logging
|
|
|
|
|
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
|
2010-12-05 15:59:11 +00:00
|
|
|
#define GENERIC_LOG(t, v, ...) { \
|
|
|
|
if (v <= MAX_LOGLEVEL) \
|
|
|
|
GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
|
|
|
|
}
|
2009-05-03 11:15:17 +00:00
|
|
|
#endif
|
2009-03-07 08:35:01 +00:00
|
|
|
|
2012-08-20 11:12:49 +00:00
|
|
|
#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0)
|
|
|
|
#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0)
|
|
|
|
#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0)
|
|
|
|
#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)
|
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_update_() ;
|
|
|
|
|
|
|
|
#ifndef _dbg_assert_
|
2010-07-31 19:06:44 +00:00
|
|
|
#define _dbg_assert_(_t_, _a_) {}
|
|
|
|
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
|
2009-03-07 08:35:01 +00:00
|
|
|
#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_
|