tools/Master.cpp
changeset 956 d9b9bc794d10
parent 951 dc84a0af63da
child 957 ed5ac2e83495
--- a/tools/Master.cpp	Thu Jun 05 12:39:46 2008 +0000
+++ b/tools/Master.cpp	Thu Jun 05 14:33:36 2008 +0000
@@ -77,6 +77,35 @@
 
 /****************************************************************************/
 
+void Master::setDebug(const vector<string> &commandArgs)
+{
+    stringstream str;
+    int debugLevel;
+    
+    if (commandArgs.size() != 1) {
+        stringstream err;
+        err << "'debug' takes exactly one argument!";
+        throw MasterException(err.str());
+    }
+
+    str << commandArgs[0];
+    str >> debugLevel;
+
+    if (str.fail()) {
+        stringstream err;
+        err << "Invalid debug level '" << commandArgs[0] << "'!";
+        throw MasterException(err.str());
+    }
+
+    if (ioctl(fd, EC_IOCTL_DEBUG_LEVEL, debugLevel) < 0) {
+        stringstream err;
+        err << "Failed to set debug level: " << strerror(errno);
+        throw MasterException(err.str());
+    }
+}
+
+/****************************************************************************/
+
 void Master::showDomains(int domainIndex)
 {
     if (domainIndex == -1) {