GUI: Add "debuglevel" command to Debugger base class.

This allows the debug level to be changed at runtime from the debug
console.
This commit is contained in:
D G Turner 2014-05-10 17:08:34 +01:00
parent 0549ae8259
commit bc7af1de19
2 changed files with 18 additions and 0 deletions

View File

@ -61,6 +61,7 @@ Debugger::Debugger() {
DCmd_Register("help", WRAP_METHOD(Debugger, Cmd_Help));
DCmd_Register("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog));
DCmd_Register("debuglevel", WRAP_METHOD(Debugger, Cmd_DebugLevel));
DCmd_Register("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList));
DCmd_Register("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable));
DCmd_Register("debugflag_disable", WRAP_METHOD(Debugger, Cmd_DebugFlagDisable));
@ -501,6 +502,22 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) {
}
bool Debugger::Cmd_DebugLevel(int argc, const char **argv) {
if (argc == 1) {
DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel);
} else { // set level
gDebugLevel = atoi(argv[1]);
if (gDebugLevel >= 0 && gDebugLevel < 11) {
DebugPrintf("Debug level set to level %d\n", gDebugLevel);
} else if (gDebugLevel < 0) {
DebugPrintf("Debugging is now disabled\n");
} else
DebugPrintf("Not a valid debug level (0 - 10)\n");
}
return true;
}
bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) {
const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels();

View File

@ -193,6 +193,7 @@ protected:
bool Cmd_Exit(int argc, const char **argv);
bool Cmd_Help(int argc, const char **argv);
bool Cmd_OpenLog(int argc, const char **argv);
bool Cmd_DebugLevel(int argc, const char **argv);
bool Cmd_DebugFlagsList(int argc, const char **argv);
bool Cmd_DebugFlagEnable(int argc, const char **argv);
bool Cmd_DebugFlagDisable(int argc, const char **argv);