~ppsspp/ppsspp/ppsspp_1.3.0

« back to all changes in this revision

Viewing changes to Common/Log.h

  • Committer: Sérgio Benjamim
  • Date: 2017-01-02 00:12:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20170102001205-cxbta9za203nmjwm
1.3.0 source (from ppsspp_1.3.0-r160.p5.l1762.a165.t83~56~ubuntu16.04.1.tar.xz).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2003 Dolphin Project.
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
12
// A copy of the GPL 2.0 should have been included with the program.
 
13
// If not, see http://www.gnu.org/licenses/
 
14
 
 
15
// Official SVN repository and contact information can be found at
 
16
// http://code.google.com/p/dolphin-emu/
 
17
 
 
18
#pragma once
 
19
 
 
20
#include "MsgHandler.h"
 
21
 
 
22
#ifdef __arm__
 
23
#if !defined(ARM)
 
24
#define ARM
 
25
#endif
 
26
#endif
 
27
 
 
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.
 
34
 
 
35
#if !defined(_WIN32)
 
36
#include <signal.h>
 
37
#endif
 
38
 
 
39
#include <cstdio>
 
40
 
 
41
namespace LogTypes
 
42
{
 
43
 
 
44
enum LOG_TYPE {
 
45
        MASTER_LOG,
 
46
 
 
47
        SCEAUDIO,
 
48
        SCECTRL,
 
49
        SCEDISPLAY,
 
50
        SCEFONT,
 
51
        SCEGE,
 
52
        SCEINTC,
 
53
        SCEIO,
 
54
        SCEKERNEL,
 
55
        SCEMODULE,
 
56
        SCENET,
 
57
        SCERTC,
 
58
        SCESAS,
 
59
        SCEUTILITY,
 
60
 
 
61
        BOOT,
 
62
        COMMON,
 
63
        CPU,
 
64
        FILESYS,
 
65
        G3D,
 
66
        HLE,  // dumping ground that we should get rid off
 
67
        JIT,
 
68
        LOADER,
 
69
        ME,
 
70
        MEMMAP,
 
71
        TIME,
 
72
        SASMIX,
 
73
 
 
74
        NUMBER_OF_LOGS,  // Must be last
 
75
};
 
76
 
 
77
enum LOG_LEVELS {
 
78
        LNOTICE = NOTICE_LEVEL,
 
79
        LERROR = ERROR_LEVEL,
 
80
        LWARNING = WARNING_LEVEL,
 
81
        LINFO = INFO_LEVEL,
 
82
        LDEBUG = DEBUG_LEVEL,
 
83
        LVERBOSE = VERBOSE_LEVEL,
 
84
};
 
85
 
 
86
}  // namespace
 
87
 
 
88
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
 
89
                const char *file, int line, const char *fmt, ...)
 
90
#ifdef __GNUC__
 
91
                __attribute__((format(printf, 5, 6)))
 
92
#endif
 
93
                ;
 
94
bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type);
 
95
 
 
96
#if defined(LOGGING) || defined(_DEBUG) || defined(DEBUGFAST) || defined(_WIN32)
 
97
#define MAX_LOGLEVEL DEBUG_LEVEL
 
98
#else
 
99
#ifndef MAX_LOGLEVEL
 
100
#define MAX_LOGLEVEL INFO_LEVEL
 
101
#endif // loglevel
 
102
#endif // logging
 
103
 
 
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__); \
 
108
        }
 
109
 
 
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)
 
116
 
 
117
#if MAX_LOGLEVEL >= DEBUG_LEVEL
 
118
#define _dbg_assert_(_t_, _a_) \
 
119
        if (!(_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();} \
 
123
        }
 
124
#ifdef __SYMBIAN32__
 
125
#define _dbg_assert_msg_(_t_, _a_, ...) if (!(_a_)) ERROR_LOG(_t_, __VA_ARGS__);
 
126
#else
 
127
#define _dbg_assert_msg_(_t_, _a_, ...)\
 
128
        if (!(_a_)) {\
 
129
                printf(__VA_ARGS__); \
 
130
                ERROR_LOG(_t_, __VA_ARGS__); \
 
131
                if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
 
132
        }
 
133
#endif
 
134
#define _dbg_update_() ; //Host_UpdateLogDisplay();
 
135
 
 
136
#else // not debug
 
137
#define _dbg_update_() ;
 
138
 
 
139
#ifndef _dbg_assert_
 
140
#define _dbg_assert_(_t_, _a_) {}
 
141
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
 
142
#endif // dbg_assert
 
143
#endif // MAX_LOGLEVEL DEBUG
 
144
 
 
145
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
 
146
 
 
147
#ifdef _MSC_VER
 
148
#define _assert_msg_(_t_, _a_, _fmt_, ...)              \
 
149
        if (!(_a_)) {\
 
150
                if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
 
151
        }
 
152
#else // not win32
 
153
#define _assert_msg_(_t_, _a_, _fmt_, ...)              \
 
154
        if (!(_a_)) {\
 
155
                if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
 
156
        }
 
157
#endif // WIN32