diff options
Diffstat (limited to 'src/common/log.h')
| -rw-r--r-- | src/common/log.h | 125 |
1 files changed, 5 insertions, 120 deletions
diff --git a/src/common/log.h b/src/common/log.h index 78f0dae4d..663eda9ad 100644 --- a/src/common/log.h +++ b/src/common/log.h | |||
| @@ -6,105 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/common_funcs.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/msg_handler.h" | 8 | #include "common/msg_handler.h" |
| 9 | 9 | #include "common/logging/log.h" | |
| 10 | #ifndef LOGGING | ||
| 11 | #define LOGGING | ||
| 12 | #endif | ||
| 13 | |||
| 14 | enum { | ||
| 15 | OS_LEVEL, // Printed by the emulated operating system | ||
| 16 | NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports. | ||
| 17 | ERROR_LEVEL, // Critical errors | ||
| 18 | WARNING_LEVEL, // Something is suspicious. | ||
| 19 | INFO_LEVEL, // General information. | ||
| 20 | DEBUG_LEVEL, // Detailed debugging - might make things slow. | ||
| 21 | }; | ||
| 22 | |||
| 23 | namespace LogTypes | ||
| 24 | { | ||
| 25 | |||
| 26 | enum LOG_TYPE { | ||
| 27 | ACTIONREPLAY, | ||
| 28 | AUDIO, | ||
| 29 | AUDIO_INTERFACE, | ||
| 30 | BOOT, | ||
| 31 | COMMANDPROCESSOR, | ||
| 32 | COMMON, | ||
| 33 | CONSOLE, | ||
| 34 | CONFIG, | ||
| 35 | DISCIO, | ||
| 36 | FILEMON, | ||
| 37 | DSPHLE, | ||
| 38 | DSPLLE, | ||
| 39 | DSP_MAIL, | ||
| 40 | DSPINTERFACE, | ||
| 41 | DVDINTERFACE, | ||
| 42 | DYNA_REC, | ||
| 43 | EXPANSIONINTERFACE, | ||
| 44 | GDB_STUB, | ||
| 45 | ARM11, | ||
| 46 | GSP, | ||
| 47 | OSHLE, | ||
| 48 | MASTER_LOG, | ||
| 49 | MEMMAP, | ||
| 50 | MEMCARD_MANAGER, | ||
| 51 | OSREPORT, | ||
| 52 | PAD, | ||
| 53 | PROCESSORINTERFACE, | ||
| 54 | PIXELENGINE, | ||
| 55 | SERIALINTERFACE, | ||
| 56 | SP1, | ||
| 57 | STREAMINGINTERFACE, | ||
| 58 | VIDEO, | ||
| 59 | VIDEOINTERFACE, | ||
| 60 | LOADER, | ||
| 61 | FILESYS, | ||
| 62 | WII_IPC_DVD, | ||
| 63 | WII_IPC_ES, | ||
| 64 | WII_IPC_FILEIO, | ||
| 65 | WII_IPC_HID, | ||
| 66 | KERNEL, | ||
| 67 | SVC, | ||
| 68 | HLE, | ||
| 69 | RENDER, | ||
| 70 | GPU, | ||
| 71 | HW, | ||
| 72 | TIME, | ||
| 73 | NETPLAY, | ||
| 74 | GUI, | ||
| 75 | |||
| 76 | NUMBER_OF_LOGS // Must be last | ||
| 77 | }; | ||
| 78 | |||
| 79 | // FIXME: should this be removed? | ||
| 80 | enum LOG_LEVELS { | ||
| 81 | LOS = OS_LEVEL, | ||
| 82 | LNOTICE = NOTICE_LEVEL, | ||
| 83 | LERROR = ERROR_LEVEL, | ||
| 84 | LWARNING = WARNING_LEVEL, | ||
| 85 | LINFO = INFO_LEVEL, | ||
| 86 | LDEBUG = DEBUG_LEVEL, | ||
| 87 | }; | ||
| 88 | |||
| 89 | #define LOGTYPES_LEVELS LogTypes::LOG_LEVELS | ||
| 90 | #define LOGTYPES_TYPE LogTypes::LOG_TYPE | ||
| 91 | |||
| 92 | } // namespace | ||
| 93 | |||
| 94 | void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line, | ||
| 95 | const char* function, const char* fmt, ...) | ||
| 96 | #ifdef __GNUC__ | ||
| 97 | __attribute__((format(printf, 6, 7))) | ||
| 98 | #endif | ||
| 99 | ; | ||
| 100 | |||
| 101 | #if defined LOGGING || defined _DEBUG || defined DEBUGFAST | ||
| 102 | #define MAX_LOGLEVEL LDEBUG | ||
| 103 | #else | ||
| 104 | #ifndef MAX_LOGLEVEL | ||
| 105 | #define MAX_LOGLEVEL LWARNING | ||
| 106 | #endif // loglevel | ||
| 107 | #endif // logging | ||
| 108 | 10 | ||
| 109 | #ifdef _WIN32 | 11 | #ifdef _WIN32 |
| 110 | #ifndef __func__ | 12 | #ifndef __func__ |
| @@ -112,29 +14,16 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int | |||
| 112 | #endif | 14 | #endif |
| 113 | #endif | 15 | #endif |
| 114 | 16 | ||
| 115 | // Let the compiler optimize this out | 17 | #if _DEBUG |
| 116 | #define GENERIC_LOG(t, v, ...) { \ | ||
| 117 | if (v <= LogTypes::MAX_LOGLEVEL) \ | ||
| 118 | GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \ | ||
| 119 | } | ||
| 120 | |||
| 121 | #define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __VA_ARGS__) } while (0) | ||
| 122 | #define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0) | ||
| 123 | #define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0) | ||
| 124 | #define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0) | ||
| 125 | #define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0) | ||
| 126 | #define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0) | ||
| 127 | |||
| 128 | #if MAX_LOGLEVEL >= DEBUG_LEVEL | ||
| 129 | #define _dbg_assert_(_t_, _a_) \ | 18 | #define _dbg_assert_(_t_, _a_) \ |
| 130 | if (!(_a_)) {\ | 19 | if (!(_a_)) {\ |
| 131 | ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ | 20 | LOG_CRITICAL(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ |
| 132 | __LINE__, __FILE__, __TIME__); \ | 21 | __LINE__, __FILE__, __TIME__); \ |
| 133 | if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \ | 22 | if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \ |
| 134 | } | 23 | } |
| 135 | #define _dbg_assert_msg_(_t_, _a_, ...)\ | 24 | #define _dbg_assert_msg_(_t_, _a_, ...)\ |
| 136 | if (!(_a_)) {\ | 25 | if (!(_a_)) {\ |
| 137 | ERROR_LOG(_t_, __VA_ARGS__); \ | 26 | LOG_CRITICAL(_t_, __VA_ARGS__); \ |
| 138 | if (!PanicYesNo(__VA_ARGS__)) {Crash();} \ | 27 | if (!PanicYesNo(__VA_ARGS__)) {Crash();} \ |
| 139 | } | 28 | } |
| 140 | #define _dbg_update_() Host_UpdateLogDisplay(); | 29 | #define _dbg_update_() Host_UpdateLogDisplay(); |
| @@ -146,11 +35,10 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int | |||
| 146 | #define _dbg_assert_(_t_, _a_) {} | 35 | #define _dbg_assert_(_t_, _a_) {} |
| 147 | #define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {} | 36 | #define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {} |
| 148 | #endif // dbg_assert | 37 | #endif // dbg_assert |
| 149 | #endif // MAX_LOGLEVEL DEBUG | 38 | #endif |
| 150 | 39 | ||
| 151 | #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) | 40 | #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) |
| 152 | 41 | ||
| 153 | #ifndef GEKKO | ||
| 154 | #ifdef _WIN32 | 42 | #ifdef _WIN32 |
| 155 | #define _assert_msg_(_t_, _a_, _fmt_, ...) \ | 43 | #define _assert_msg_(_t_, _a_, _fmt_, ...) \ |
| 156 | if (!(_a_)) {\ | 44 | if (!(_a_)) {\ |
| @@ -162,6 +50,3 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int | |||
| 162 | if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ | 50 | if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ |
| 163 | } | 51 | } |
| 164 | #endif // WIN32 | 52 | #endif // WIN32 |
| 165 | #else // GEKKO | ||
| 166 | #define _assert_msg_(_t_, _a_, _fmt_, ...) | ||
| 167 | #endif | ||