fp@1142: /***************************************************************************** fp@1142: * fp@1142: * $Id$ fp@1142: * fp@1142: ****************************************************************************/ fp@1142: fp@1142: #include fp@1142: #include fp@1142: using namespace std; fp@1142: fp@1142: #include "CommandDebug.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: CommandDebug::CommandDebug(): fp@1142: Command("debug", "Set the master's debug level.") fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: string CommandDebug::helpString() const fp@1142: { fp@1142: stringstream str; fp@1142: fp@1142: str << getName() << " " << endl fp@1142: << endl fp@1142: << getBriefDescription() << endl fp@1142: << endl fp@1142: << "Debug messages are printed to syslog." << endl fp@1142: << endl fp@1142: << "Arguments:" << endl fp@1142: << " LEVEL can have one of the following values:" << endl fp@1142: << " 0 for no debugging output," << endl fp@1142: << " 1 for some debug messages, or" << endl fp@1142: << " 2 for printing all frame contents (use with caution!)." fp@1142: << endl << endl fp@1142: << numericInfo(); fp@1142: fp@1142: return str.str(); fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandDebug::execute(MasterDevice &m, const StringVector &args) fp@1142: { fp@1142: stringstream str; fp@1142: int debugLevel; fp@1142: fp@1142: if (args.size() != 1) { fp@1142: stringstream err; fp@1142: err << "'" << getName() << "' takes exactly one argument!"; fp@1142: throwInvalidUsageException(err); fp@1142: } fp@1142: fp@1142: str << args[0]; fp@1142: str >> resetiosflags(ios::basefield) // guess base from prefix fp@1142: >> debugLevel; fp@1142: fp@1142: if (str.fail()) { fp@1142: stringstream err; fp@1142: err << "Invalid debug level '" << args[0] << "'!"; fp@1142: throwInvalidUsageException(err); fp@1142: } fp@1142: fp@1142: m.open(MasterDevice::ReadWrite); fp@1142: m.setDebug(debugLevel); fp@1142: } fp@1142: fp@1142: /*****************************************************************************/