xoreos
0.0.5
|
The debug manager, managing debug channels. More...
#include <debugman.h>
Classes | |
struct | Channel |
A debug channel. More... | |
Public Member Functions | |
DebugManager () | |
~DebugManager () | |
void | getDebugChannels (std::vector< UString > &names, std::vector< UString > &descriptions) const |
Return the channel names alongside their descriptions. More... | |
void | setVerbosityLevel (DebugChannel channel, uint32 level) |
Set the verbosity level of this channel (by ID). More... | |
void | setVerbosityLevel (const UString &channel, uint32 level) |
Set the verbosity level of this channel (by name). More... | |
uint32 | getVerbosityLevel (DebugChannel channel) const |
Return the verbosity level of this channel (by ID). More... | |
uint32 | getVerbosityLevel (const UString &channel) const |
Return the verbosity level of this channel (by name). More... | |
bool | isEnabled (DebugChannel channel, uint32 level) const |
Is this channel ID enabled for this verbosity level? More... | |
bool | isEnabled (const UString &channel, uint32 level) const |
Is this channel name enabled for this verbosity level? More... | |
void | setVerbosityLevelsFromConfig () |
Sync verbosity levels from the ConfigManager. More... | |
void | setConfigToVerbosityLevels () |
Sync verbosity levels to the ConfigManager. More... | |
void | logDebugGL (DebugChannel channel, uint32 level, DebugGLType type, uint32 id, const char *msg) |
Log (and print) an OpenGL debug message. More... | |
bool | openLogFile (const UString &file) |
Open a log file where all debug output will be written to. More... | |
void | closeLogFile () |
Close the current log file. More... | |
void | logString (const UString &str) |
Log that string to the current log file. More... | |
void | logCommandLine (const std::vector< UString > &argv) |
Write the whole command line to the current log file. More... | |
Static Public Member Functions | |
static UString | getDefaultLogFile () |
Return the OS-specific default path of the log file. More... | |
Static Public Member Functions inherited from Common::Singleton< DebugManager > | |
static DebugManager & | instance () |
static void | destroy () |
Static Public Attributes | |
static const uint32 | kMaxVerbosityLevel = 9 |
Private Types | |
typedef std::map< UString, DebugChannel, UString::iless > | ChannelMap |
Private Attributes | |
Channel | _channels [kDebugChannelCount] |
All debug channels. More... | |
ChannelMap | _channelMap |
Debug channels indexed by name. More... | |
WriteFile | _logFile |
bool | _logFileStartLine |
bool | _changedConfig |
Additional Inherited Members | |
Protected Types inherited from Common::Singleton< DebugManager > | |
typedef DebugManager | SingletonBaseType |
Protected Member Functions inherited from Common::Singleton< DebugManager > | |
Singleton () | |
virtual | ~Singleton () |
The debug manager, managing debug channels.
A debug channel separates debug messages into groups, so debug output doesn't get swamped unnecessarily.
Each debug channel is associated with a verbosity "level" at which it is currently enabled, and each debug message is sent to a channel with a number specifying its verbosity level. The debug message is then only shown when the debug channel it belongs to is enabled at a verbosity level equal to or higher than the debug message's verbosity level.
The verbosity levels go from 0 (disabled) to 9 (most verbose).
For example:
There are two debug channels, C1 and C2. C1 is enabled at verbosity level 3 and C2 is enabled at verbosity level 0 (i.e. disabled). These three debug messages arrive: 1) Channel C1, level 3 2) Channel C1, level 4 3) Channel C2, level 1
In this scenario, only message 1, the one at channel C1 with a level of 3 is shown. Message 2 is not shown, because with a level of 4 it exceeds the current level of C1, which is 3. Likewise, the level of message 3, 1, exceeds the current level of C2. In fact, with a current level of 0, no messages will be shown for C2 at all, ever.
Definition at line 108 of file debugman.h.
|
private |
Definition at line 181 of file debugman.h.
Common::DebugManager::DebugManager | ( | ) |
Definition at line 72 of file debugman.cpp.
References _channelMap, _channels, Common::DebugManager::Channel::description, Common::kDebugChannelAll, Common::kDebugChannelCount, Common::kDebugDescriptions, Common::kDebugGLTypeMAX, Common::kDebugNames, Common::DebugManager::Channel::level, and Common::DebugManager::Channel::name.
Common::DebugManager::~DebugManager | ( | ) |
Definition at line 87 of file debugman.cpp.
References closeLogFile().
void Common::DebugManager::closeLogFile | ( | ) |
Close the current log file.
Definition at line 243 of file debugman.cpp.
References _logFile, and Common::WriteFile::close().
Referenced by openLogFile(), and ~DebugManager().
void Common::DebugManager::getDebugChannels | ( | std::vector< UString > & | names, |
std::vector< UString > & | descriptions | ||
) | const |
Return the channel names alongside their descriptions.
Definition at line 91 of file debugman.cpp.
References _channels, Common::DebugManager::Channel::description, Common::kDebugChannelCount, and Common::DebugManager::Channel::name.
|
static |
Return the OS-specific default path of the log file.
Definition at line 287 of file debugman.cpp.
References Common::FilePath::getUserDataDirectory().
uint32 Common::DebugManager::getVerbosityLevel | ( | DebugChannel | channel | ) | const |
Return the verbosity level of this channel (by ID).
Definition at line 128 of file debugman.cpp.
References _channels, Common::kDebugChannelCount, and Common::DebugManager::Channel::level.
Referenced by getVerbosityLevel(), and isEnabled().
Return the verbosity level of this channel (by name).
Definition at line 135 of file debugman.cpp.
References _channelMap, and getVerbosityLevel().
bool Common::DebugManager::isEnabled | ( | DebugChannel | channel, |
uint32 | level | ||
) | const |
Is this channel ID enabled for this verbosity level?
Definition at line 143 of file debugman.cpp.
References getVerbosityLevel(), and kMaxVerbosityLevel.
Referenced by logDebugGL().
Is this channel name enabled for this verbosity level?
Definition at line 147 of file debugman.cpp.
References getVerbosityLevel(), and kMaxVerbosityLevel.
void Common::DebugManager::logCommandLine | ( | const std::vector< UString > & | argv | ) |
Write the whole command line to the current log file.
Definition at line 278 of file debugman.cpp.
References logString().
void Common::DebugManager::logDebugGL | ( | DebugChannel | channel, |
uint32 | level, | ||
DebugGLType | type, | ||
uint32 | id, | ||
const char * | msg | ||
) |
Log (and print) an OpenGL debug message.
Definition at line 202 of file debugman.cpp.
References _channels, Common::DebugManager::Channel::glTypeIDs, isEnabled(), Common::isOpenGLDebugChannel(), Common::kDebugGLTypeMAX, Common::kDebugGLTypeOther, Common::kDebugGLTypes, Common::kDebugNames, and status().
void Common::DebugManager::logString | ( | const UString & | str | ) |
Log that string to the current log file.
Definition at line 247 of file debugman.cpp.
References _logFile, _logFileStartLine, Common::UString::empty(), Common::UString::end(), Common::WriteFile::flush(), Common::DateTime::formatDateTimeISO(), Common::WriteFile::isOpen(), Common::DateTime::kUTC, and Common::WriteStream::writeString().
Referenced by logCommandLine(), and openLogFile().
bool Common::DebugManager::openLogFile | ( | const UString & | file | ) |
Open a log file where all debug output will be written to.
For ease of debugging and build identification, the xoreos version string will be the first line written to the file.
Definition at line 220 of file debugman.cpp.
References _logFile, _logFileStartLine, Common::FilePath::canonicalize(), closeLogFile(), Common::FilePath::createDirectories(), Common::FilePath::getDirectory(), Version::getProjectNameVersionFull(), logString(), and Common::WriteFile::open().
void Common::DebugManager::setConfigToVerbosityLevels | ( | ) |
Sync verbosity levels to the ConfigManager.
This writes the current verbosity levels of all debug channels into the "debug" config option of the ConfigManager.
Definition at line 179 of file debugman.cpp.
References _changedConfig, _channels, Common::composeString(), ConfigMan, Common::UString::empty(), Common::kDebugChannelCount, and Common::DebugManager::Channel::name.
void Common::DebugManager::setVerbosityLevel | ( | DebugChannel | channel, |
uint32 | level | ||
) |
Set the verbosity level of this channel (by ID).
Definition at line 101 of file debugman.cpp.
References _changedConfig, _channels, Common::kDebugChannelAll, Common::kDebugChannelCount, Common::kDebugGLTypeMAX, kMaxVerbosityLevel, and Common::DebugManager::Channel::level.
Referenced by setVerbosityLevel(), and setVerbosityLevelsFromConfig().
Set the verbosity level of this channel (by name).
Definition at line 120 of file debugman.cpp.
References _channelMap, and setVerbosityLevel().
void Common::DebugManager::setVerbosityLevelsFromConfig | ( | ) |
Sync verbosity levels from the ConfigManager.
This reads the current value of the "debug" config option from the ConfigManager, parses it, and sets the verbosity levels of all debug channels according to this value.
Definition at line 151 of file debugman.cpp.
References _changedConfig, ConfigMan, Common::kDebugChannelAll, Common::parseString(), setVerbosityLevel(), and Common::UString::split().
|
private |
Definition at line 189 of file debugman.h.
Referenced by setConfigToVerbosityLevels(), setVerbosityLevel(), and setVerbosityLevelsFromConfig().
|
private |
Debug channels indexed by name.
Definition at line 184 of file debugman.h.
Referenced by DebugManager(), getVerbosityLevel(), and setVerbosityLevel().
|
private |
All debug channels.
Definition at line 183 of file debugman.h.
Referenced by DebugManager(), getDebugChannels(), getVerbosityLevel(), logDebugGL(), setConfigToVerbosityLevels(), and setVerbosityLevel().
|
private |
Definition at line 186 of file debugman.h.
Referenced by closeLogFile(), logString(), and openLogFile().
|
private |
Definition at line 187 of file debugman.h.
Referenced by logString(), and openLogFile().
|
static |
Definition at line 110 of file debugman.h.
Referenced by isEnabled(), and setVerbosityLevel().