xoreos  0.0.5
debugman.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 // Inspired by ScummVM's debug channels
22 
27 #ifndef COMMON_DEBUGMAN_H
28 #define COMMON_DEBUGMAN_H
29 
30 #include <vector>
31 #include <map>
32 
33 #include "src/common/types.h"
34 #include "src/common/ustring.h"
35 #include "src/common/singleton.h"
36 #include "src/common/writefile.h"
37 
38 namespace Common {
39 
47 
54 
61 
63 
66 };
67 
76 
78 };
79 
108 class DebugManager : public Singleton<DebugManager> {
109 public:
110  static const uint32 kMaxVerbosityLevel = 9;
111 
112  DebugManager();
113  ~DebugManager();
114 
116  void getDebugChannels(std::vector<UString> &names, std::vector<UString> &descriptions) const;
117 
119  void setVerbosityLevel(DebugChannel channel, uint32 level);
121  void setVerbosityLevel(const UString &channel, uint32 level);
122 
124  uint32 getVerbosityLevel(DebugChannel channel) const;
126  uint32 getVerbosityLevel(const UString &channel) const;
127 
129  bool isEnabled(DebugChannel channel, uint32 level) const;
131  bool isEnabled(const UString &channel, uint32 level) const;
132 
140 
147 
149  void logDebugGL(DebugChannel channel, uint32 level, DebugGLType type, uint32 id, const char *msg);
150 
156  bool openLogFile(const UString &file);
158  void closeLogFile();
159 
161  void logString(const UString &str);
162 
164  void logCommandLine(const std::vector<UString> &argv);
165 
167  static UString getDefaultLogFile();
168 
169 private:
171  struct Channel {
174 
176 
179  };
180 
181  typedef std::map<UString, DebugChannel, UString::iless> ChannelMap;
182 
185 
188 
190 };
191 
192 } // End of namespace Common
193 
195 #define DebugMan Common::DebugManager::instance()
196 
197 #endif // COMMON_DEBUGMAN_H
Class and macro for implementing singletons.
"GSound", global, non-engine sound.
Definition: debugman.h:43
Behavior that has been marked for deprecation.
Definition: debugman.h:71
"GGLAPI", OpenGL debug message generated by the GL.
Definition: debugman.h:48
Definition: 2dafile.h:39
static const uint32 kMaxVerbosityLevel
Definition: debugman.h:110
A class holding an UTF-8 string.
Definition: ustring.h:48
"GGLWindow", OpenGL debug message generated by the windowing system.
Definition: debugman.h:49
void logString(const UString &str)
Log that string to the current log file.
Definition: debugman.cpp:247
"GActionScript", actionscript interpreter
Definition: debugman.h:62
"GEvents", global, non-engine events.
Definition: debugman.h:45
uint32 glTypeIDs[kDebugGLTypeMAX]
Information about the last OpenGL message ID for this channel&#39;s types.
Definition: debugman.h:178
uint32 getVerbosityLevel(DebugChannel channel) const
Return the verbosity level of this channel (by ID).
Definition: debugman.cpp:128
bool isEnabled(DebugChannel channel, uint32 level) const
Is this channel ID enabled for this verbosity level?
Definition: debugman.cpp:143
"EScripts", engine scripts.
Definition: debugman.h:59
ChannelMap _channelMap
Debug channels indexed by name.
Definition: debugman.h:184
UString description
The channel&#39;s description.
Definition: debugman.h:173
void setConfigToVerbosityLevels()
Sync verbosity levels to the ConfigManager.
Definition: debugman.cpp:179
static UString getDefaultLogFile()
Return the OS-specific default path of the log file.
Definition: debugman.cpp:287
A debug channel.
Definition: debugman.h:171
std::map< UString, DebugChannel, UString::iless > ChannelMap
Definition: debugman.h:181
void logDebugGL(DebugChannel channel, uint32 level, DebugGLType type, uint32 id, const char *msg)
Log (and print) an OpenGL debug message.
Definition: debugman.cpp:202
"EVideo", engine video.
Definition: debugman.h:57
The debug manager, managing debug channels.
Definition: debugman.h:108
WriteFile _logFile
Definition: debugman.h:186
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
void closeLogFile()
Close the current log file.
Definition: debugman.cpp:243
"GVideo", global, non-engine video (movies).
Definition: debugman.h:44
Special value to refer to all debug channel.
Definition: debugman.h:65
void logCommandLine(const std::vector< UString > &argv)
Write the whole command line to the current log file.
Definition: debugman.cpp:278
"GGraphics", global, non-engine graphics.
Definition: debugman.h:42
"GGLApp", OpenGL debug message generated by the application.
Definition: debugman.h:52
DebugGLType
Types of OpenGL debug messages.
Definition: debugman.h:69
Events that generated an error.
Definition: debugman.h:70
For range checks.
Definition: debugman.h:77
void getDebugChannels(std::vector< UString > &names, std::vector< UString > &descriptions) const
Return the channel names alongside their descriptions.
Definition: debugman.cpp:91
"GScripts", global, non-engine scripts.
Definition: debugman.h:46
Low-level type definitions to handle fixed width types portably.
bool openLogFile(const UString &file)
Open a log file where all debug output will be written to.
Definition: debugman.cpp:220
Behavior that is undefined according to the specification.
Definition: debugman.h:72
"EEvents", engine events.
Definition: debugman.h:58
Total number of debug channels.
Definition: debugman.h:64
Unicode string handling.
DebugChannel
All debug channels.
Definition: debugman.h:41
"GGLOther", OpenGL debug message generated by other sources.
Definition: debugman.h:53
uint32_t uint32
Definition: types.h:204
uint32 level
The current level at which this debug channel is enabled.
Definition: debugman.h:175
Types of events that do not fit any of the ones listed above.
Definition: debugman.h:75
Implementing the stream writing interfaces for files.
Use of extensions or shaders in a way that is highly vendor-specific.
Definition: debugman.h:74
Channel _channels[kDebugChannelCount]
All debug channels.
Definition: debugman.h:183
void setVerbosityLevelsFromConfig()
Sync verbosity levels from the ConfigManager.
Definition: debugman.cpp:151
"EGraphics", engine graphics.
Definition: debugman.h:55
"GGL3rd", OpenGL debug message generated by third party middleware.
Definition: debugman.h:51
void setVerbosityLevel(DebugChannel channel, uint32 level)
Set the verbosity level of this channel (by ID).
Definition: debugman.cpp:101
A simple streaming file writing class.
Definition: writefile.h:40
"ELogic", engine game logic.
Definition: debugman.h:60
"GGLShader", OpenGL debug message generated by the shader compiler.
Definition: debugman.h:50
UString name
The channel&#39;s name.
Definition: debugman.h:172
"ESound", engine sound.
Definition: debugman.h:56
Implementation-dependent performance warnings.
Definition: debugman.h:73