1
// Copyright (C) 2003 Dolphin Project.
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
15
// Official SVN repository and contact information can be found at
16
// http://code.google.com/p/dolphin-emu/
20
#include "MsgHandler.h"
28
#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and debugprintfs from the game itself.
29
#define ERROR_LEVEL 2 // Important errors.
30
#define WARNING_LEVEL 3 // Something is suspicious.
31
#define INFO_LEVEL 4 // General information.
32
#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow.
33
#define VERBOSE_LEVEL 6 // Noisy debugging - sometimes needed but usually unimportant.
66
HLE, // dumping ground that we should get rid off
74
NUMBER_OF_LOGS, // Must be last
78
LNOTICE = NOTICE_LEVEL,
80
LWARNING = WARNING_LEVEL,
83
LVERBOSE = VERBOSE_LEVEL,
88
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
89
const char *file, int line, const char *fmt, ...)
91
__attribute__((format(printf, 5, 6)))
94
bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type);
96
#if defined(LOGGING) || defined(_DEBUG) || defined(DEBUGFAST) || defined(_WIN32)
97
#define MAX_LOGLEVEL DEBUG_LEVEL
100
#define MAX_LOGLEVEL INFO_LEVEL
104
// Let the compiler optimize this out
105
#define GENERIC_LOG(t, v, ...) { \
106
if (v <= MAX_LOGLEVEL) \
107
GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
110
#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (false)
111
#define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (false)
112
#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (false)
113
#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (false)
114
#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (false)
115
#define VERBOSE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LVERBOSE, __VA_ARGS__) } while (false)
117
#if MAX_LOGLEVEL >= DEBUG_LEVEL
118
#define _dbg_assert_(_t_, _a_) \
120
ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n\nIgnore and continue?", \
121
__LINE__, __FILE__); \
122
if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \
125
#define _dbg_assert_msg_(_t_, _a_, ...) if (!(_a_)) ERROR_LOG(_t_, __VA_ARGS__);
127
#define _dbg_assert_msg_(_t_, _a_, ...)\
129
printf(__VA_ARGS__); \
130
ERROR_LOG(_t_, __VA_ARGS__); \
131
if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
134
#define _dbg_update_() ; //Host_UpdateLogDisplay();
137
#define _dbg_update_() ;
140
#define _dbg_assert_(_t_, _a_) {}
141
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
143
#endif // MAX_LOGLEVEL DEBUG
145
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
148
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
150
if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
153
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
155
if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \