2013-09-05 01:17:46 +01:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-08-17 18:45:50 +01:00
|
|
|
#pragma once
|
2013-09-05 01:17:46 +01:00
|
|
|
|
2014-08-23 02:09:14 +01:00
|
|
|
#ifndef LOGGING
|
2014-05-10 01:54:51 +01:00
|
|
|
#define LOGGING
|
2014-08-23 02:09:14 +01:00
|
|
|
#endif
|
2014-05-10 01:54:51 +01:00
|
|
|
|
2014-05-30 04:03:03 +01:00
|
|
|
enum {
|
|
|
|
OS_LEVEL, // Printed by the emulated operating system
|
|
|
|
NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports.
|
|
|
|
ERROR_LEVEL, // Critical errors
|
|
|
|
WARNING_LEVEL, // Something is suspicious.
|
|
|
|
INFO_LEVEL, // General information.
|
|
|
|
DEBUG_LEVEL, // Detailed debugging - might make things slow.
|
|
|
|
};
|
2013-09-05 01:17:46 +01:00
|
|
|
|
|
|
|
namespace LogTypes
|
|
|
|
{
|
|
|
|
|
|
|
|
enum LOG_TYPE {
|
2014-04-01 23:20:08 +01:00
|
|
|
ACTIONREPLAY,
|
|
|
|
AUDIO,
|
|
|
|
AUDIO_INTERFACE,
|
|
|
|
BOOT,
|
|
|
|
COMMANDPROCESSOR,
|
|
|
|
COMMON,
|
|
|
|
CONSOLE,
|
2014-09-13 01:06:13 +01:00
|
|
|
CONFIG,
|
2014-04-01 23:20:08 +01:00
|
|
|
DISCIO,
|
|
|
|
FILEMON,
|
|
|
|
DSPHLE,
|
|
|
|
DSPLLE,
|
|
|
|
DSP_MAIL,
|
|
|
|
DSPINTERFACE,
|
|
|
|
DVDINTERFACE,
|
|
|
|
DYNA_REC,
|
|
|
|
EXPANSIONINTERFACE,
|
|
|
|
GDB_STUB,
|
|
|
|
ARM11,
|
2014-05-08 01:59:21 +01:00
|
|
|
GSP,
|
2014-04-01 23:20:08 +01:00
|
|
|
OSHLE,
|
|
|
|
MASTER_LOG,
|
|
|
|
MEMMAP,
|
|
|
|
MEMCARD_MANAGER,
|
|
|
|
OSREPORT,
|
|
|
|
PAD,
|
|
|
|
PROCESSORINTERFACE,
|
|
|
|
PIXELENGINE,
|
|
|
|
SERIALINTERFACE,
|
|
|
|
SP1,
|
|
|
|
STREAMINGINTERFACE,
|
|
|
|
VIDEO,
|
|
|
|
VIDEOINTERFACE,
|
|
|
|
LOADER,
|
|
|
|
FILESYS,
|
|
|
|
WII_IPC_DVD,
|
|
|
|
WII_IPC_ES,
|
|
|
|
WII_IPC_FILEIO,
|
|
|
|
WII_IPC_HID,
|
2014-05-10 01:54:51 +01:00
|
|
|
KERNEL,
|
2014-05-06 22:18:20 +01:00
|
|
|
SVC,
|
2014-04-18 04:43:55 +01:00
|
|
|
NDMA,
|
2014-04-11 03:43:48 +01:00
|
|
|
HLE,
|
2014-04-06 21:56:42 +01:00
|
|
|
RENDER,
|
2014-05-17 21:50:33 +01:00
|
|
|
GPU,
|
2014-04-05 03:53:34 +01:00
|
|
|
HW,
|
2014-04-01 23:20:08 +01:00
|
|
|
TIME,
|
|
|
|
NETPLAY,
|
2014-11-13 16:32:03 +00:00
|
|
|
GUI,
|
2014-04-01 23:20:08 +01:00
|
|
|
|
|
|
|
NUMBER_OF_LOGS // Must be last
|
2013-09-05 01:17:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// FIXME: should this be removed?
|
|
|
|
enum LOG_LEVELS {
|
2014-05-30 04:03:03 +01:00
|
|
|
LOS = OS_LEVEL,
|
2014-04-01 23:20:08 +01:00
|
|
|
LNOTICE = NOTICE_LEVEL,
|
|
|
|
LERROR = ERROR_LEVEL,
|
|
|
|
LWARNING = WARNING_LEVEL,
|
|
|
|
LINFO = INFO_LEVEL,
|
|
|
|
LDEBUG = DEBUG_LEVEL,
|
2013-09-05 01:17:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LOGTYPES_LEVELS LogTypes::LOG_LEVELS
|
|
|
|
#define LOGTYPES_TYPE LogTypes::LOG_TYPE
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2014-05-30 04:03:03 +01:00
|
|
|
void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line,
|
|
|
|
const char* function, const char* fmt, ...)
|
2013-09-05 01:17:46 +01:00
|
|
|
#ifdef __GNUC__
|
2014-06-01 15:57:45 +01:00
|
|
|
__attribute__((format(printf, 6, 7)))
|
2013-09-05 01:17:46 +01:00
|
|
|
#endif
|
2014-04-01 23:20:08 +01:00
|
|
|
;
|
2013-09-05 01:17:46 +01:00
|
|
|
|
|
|
|
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
|
2014-06-01 16:49:58 +01:00
|
|
|
#define MAX_LOGLEVEL LDEBUG
|
2013-09-05 01:17:46 +01:00
|
|
|
#else
|
|
|
|
#ifndef MAX_LOGLEVEL
|
2014-06-01 16:49:58 +01:00
|
|
|
#define MAX_LOGLEVEL LWARNING
|
2013-09-05 01:17:46 +01:00
|
|
|
#endif // loglevel
|
|
|
|
#endif // logging
|
|
|
|
|
2014-05-30 04:03:03 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
#ifndef __func__
|
|
|
|
#define __func__ __FUNCTION__
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-09-05 01:17:46 +01:00
|
|
|
// Let the compiler optimize this out
|
|
|
|
#define GENERIC_LOG(t, v, ...) { \
|
2014-06-01 16:49:58 +01:00
|
|
|
if (v <= LogTypes::MAX_LOGLEVEL) \
|
2014-05-30 04:03:03 +01:00
|
|
|
GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \
|
2014-04-01 23:20:08 +01:00
|
|
|
}
|
2013-09-05 01:17:46 +01:00
|
|
|
|
2014-05-30 04:03:03 +01:00
|
|
|
#define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __VA_ARGS__) } while (0)
|
2013-09-05 01:17:46 +01: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)
|
|
|
|
|
|
|
|
#if MAX_LOGLEVEL >= DEBUG_LEVEL
|
|
|
|
#define _dbg_assert_(_t_, _a_) \
|
2014-04-01 23:20:08 +01:00
|
|
|
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();} \
|
|
|
|
}
|
2013-09-05 01:17:46 +01:00
|
|
|
#define _dbg_assert_msg_(_t_, _a_, ...)\
|
2014-04-01 23:20:08 +01:00
|
|
|
if (!(_a_)) {\
|
|
|
|
ERROR_LOG(_t_, __VA_ARGS__); \
|
|
|
|
if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
2013-09-05 01:17:46 +01:00
|
|
|
#define _dbg_update_() Host_UpdateLogDisplay();
|
|
|
|
|
|
|
|
#else // not debug
|
|
|
|
#define _dbg_update_() ;
|
|
|
|
|
|
|
|
#ifndef _dbg_assert_
|
|
|
|
#define _dbg_assert_(_t_, _a_) {}
|
|
|
|
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
|
|
|
|
#endif // dbg_assert
|
|
|
|
#endif // MAX_LOGLEVEL DEBUG
|
|
|
|
|
|
|
|
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
|
|
|
|
|
|
|
#ifndef GEKKO
|
|
|
|
#ifdef _WIN32
|
2014-04-01 23:20:08 +01:00
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
|
|
|
if (!(_a_)) {\
|
|
|
|
if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
2013-09-05 01:17:46 +01:00
|
|
|
#else // not win32
|
2014-04-01 23:20:08 +01:00
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
|
|
|
if (!(_a_)) {\
|
|
|
|
if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
2013-09-05 01:17:46 +01:00
|
|
|
#endif // WIN32
|
|
|
|
#else // GEKKO
|
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...)
|
|
|
|
#endif
|