2013-04-17 21:09:55 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:09:55 -06:00
|
|
|
// Refer to the license.txt file included.
|
2009-03-07 01:35:01 -07:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-03-07 01:35:01 -07:00
|
|
|
|
2010-12-14 10:52:01 -07:00
|
|
|
namespace LogTypes
|
|
|
|
{
|
|
|
|
|
2013-10-19 16:58:02 -06:00
|
|
|
enum LOG_TYPE
|
|
|
|
{
|
2009-03-07 01:35:01 -07:00
|
|
|
ACTIONREPLAY,
|
|
|
|
AUDIO,
|
|
|
|
AUDIO_INTERFACE,
|
|
|
|
BOOT,
|
|
|
|
COMMANDPROCESSOR,
|
|
|
|
COMMON,
|
|
|
|
CONSOLE,
|
|
|
|
DISCIO,
|
2009-09-03 14:00:09 -06:00
|
|
|
FILEMON,
|
2009-03-07 01:35:01 -07:00
|
|
|
DSPHLE,
|
2009-04-06 11:12:05 -06:00
|
|
|
DSPLLE,
|
2009-07-17 19:16:17 -06:00
|
|
|
DSP_MAIL,
|
2009-03-07 01:35:01 -07:00
|
|
|
DSPINTERFACE,
|
|
|
|
DVDINTERFACE,
|
|
|
|
DYNA_REC,
|
|
|
|
EXPANSIONINTERFACE,
|
2013-01-06 03:28:27 -07:00
|
|
|
GDB_STUB,
|
2009-05-01 09:17:03 -06:00
|
|
|
POWERPC,
|
2009-03-07 01:35:01 -07:00
|
|
|
GPFIFO,
|
2010-12-05 08:59:11 -07:00
|
|
|
OSHLE,
|
2009-03-07 01:35:01 -07:00
|
|
|
MASTER_LOG,
|
|
|
|
MEMMAP,
|
2009-07-17 19:16:17 -06:00
|
|
|
MEMCARD_MANAGER,
|
2009-03-07 01:35:01 -07:00
|
|
|
OSREPORT,
|
2013-10-28 23:23:17 -06:00
|
|
|
PAD,
|
2009-10-06 09:49:20 -06:00
|
|
|
PROCESSORINTERFACE,
|
2009-03-07 01:35:01 -07:00
|
|
|
PIXELENGINE,
|
|
|
|
SERIALINTERFACE,
|
2009-05-04 13:28:53 -06:00
|
|
|
SP1,
|
2009-03-07 01:35:01 -07:00
|
|
|
STREAMINGINTERFACE,
|
|
|
|
VIDEO,
|
|
|
|
VIDEOINTERFACE,
|
|
|
|
WII_IPC,
|
|
|
|
WII_IPC_DVD,
|
|
|
|
WII_IPC_ES,
|
|
|
|
WII_IPC_FILEIO,
|
2012-03-28 02:52:17 -06:00
|
|
|
WII_IPC_HID,
|
2009-03-07 01:35:01 -07:00
|
|
|
WII_IPC_HLE,
|
|
|
|
WII_IPC_NET,
|
2013-01-04 02:35:48 -07:00
|
|
|
WII_IPC_WC24,
|
|
|
|
WII_IPC_SSL,
|
2009-03-07 01:35:01 -07:00
|
|
|
WII_IPC_SD,
|
2009-04-19 11:03:48 -06:00
|
|
|
WII_IPC_STM,
|
2009-03-07 01:35:01 -07:00
|
|
|
WII_IPC_WIIMOTE,
|
2009-03-18 11:17:58 -06:00
|
|
|
WIIMOTE,
|
2009-08-15 08:34:52 -06:00
|
|
|
NETPLAY,
|
2009-03-18 11:17:58 -06:00
|
|
|
|
2009-03-07 01:35:01 -07:00
|
|
|
NUMBER_OF_LOGS // Must be last
|
|
|
|
};
|
|
|
|
|
2013-10-19 16:58:02 -06:00
|
|
|
enum LOG_LEVELS
|
|
|
|
{
|
2014-08-21 18:11:52 -06:00
|
|
|
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.
|
2009-03-07 01:35:01 -07:00
|
|
|
};
|
|
|
|
|
2014-02-07 18:23:34 -07:00
|
|
|
static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
|
|
|
|
|
2010-12-14 10:52:01 -07:00
|
|
|
} // namespace
|
|
|
|
|
2014-07-14 13:51:28 -06:00
|
|
|
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
2010-12-05 02:04:34 -07:00
|
|
|
const char *file, int line, const char *fmt, ...)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__((format(printf, 5, 6)))
|
|
|
|
#endif
|
|
|
|
;
|
2009-03-07 01:35:01 -07:00
|
|
|
|
2009-03-18 11:17:58 -06:00
|
|
|
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
|
2014-08-21 18:11:52 -06:00
|
|
|
#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LDEBUG
|
2009-03-07 01:35:01 -07:00
|
|
|
#else
|
2009-09-01 02:44:32 -06:00
|
|
|
#ifndef MAX_LOGLEVEL
|
2014-08-21 18:11:52 -06:00
|
|
|
#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LWARNING
|
2009-09-01 02:44:32 -06:00
|
|
|
#endif // loglevel
|
2009-03-07 01:35:01 -07:00
|
|
|
#endif // logging
|
|
|
|
|
2009-05-03 05:15:17 -06:00
|
|
|
#ifdef GEKKO
|
|
|
|
#define GENERIC_LOG(t, v, ...)
|
|
|
|
#else
|
2009-03-07 01:35:01 -07:00
|
|
|
// Let the compiler optimize this out
|
2010-12-05 08:59:11 -07:00
|
|
|
#define GENERIC_LOG(t, v, ...) { \
|
|
|
|
if (v <= MAX_LOGLEVEL) \
|
|
|
|
GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
|
|
|
|
}
|
2009-05-03 05:15:17 -06:00
|
|
|
#endif
|
2009-03-07 01:35:01 -07:00
|
|
|
|
2012-08-20 05:12:49 -06: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 01:35:01 -07:00
|
|
|
|
|
|
|
#define _dbg_assert_(_t_, _a_) \
|
2014-08-21 18:11:52 -06:00
|
|
|
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) {\
|
2009-03-07 01:35:01 -07:00
|
|
|
ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
|
2014-08-21 18:11:52 -06:00
|
|
|
__LINE__, __FILE__, __TIME__); \
|
|
|
|
if (!PanicYesNo("*** Assertion (see log)***\n")) \
|
|
|
|
Crash(); \
|
2009-03-07 01:35:01 -07:00
|
|
|
}
|
2014-08-21 18:11:52 -06:00
|
|
|
|
|
|
|
#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(); \
|
2009-03-07 01:35:01 -07:00
|
|
|
}
|
2014-08-21 18:11:52 -06:00
|
|
|
#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
|
|
|
|
|
2009-03-07 01:35:01 -07:00
|
|
|
|
|
|
|
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
2009-05-03 05:15:17 -06:00
|
|
|
|
|
|
|
#ifndef GEKKO
|
2009-03-07 01:35:01 -07:00
|
|
|
#ifdef _WIN32
|
2014-02-16 21:51:41 -07:00
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
2009-03-07 01:35:01 -07:00
|
|
|
if (!(_a_)) {\
|
2014-08-21 18:11:52 -06:00
|
|
|
if (!PanicYesNo(_fmt_, __VA_ARGS__)) \
|
|
|
|
Crash(); \
|
2009-03-07 01:35:01 -07:00
|
|
|
}
|
|
|
|
#else // not win32
|
2014-02-16 21:51:41 -07:00
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
2009-03-07 01:35:01 -07:00
|
|
|
if (!(_a_)) {\
|
2014-08-21 18:11:52 -06:00
|
|
|
if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \
|
|
|
|
Crash(); \
|
2009-03-07 01:35:01 -07:00
|
|
|
}
|
|
|
|
#endif // WIN32
|
2009-05-03 05:15:17 -06:00
|
|
|
#else // GEKKO
|
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...)
|
|
|
|
#endif
|