class BaseLoop: parameter test for dump and log command added.

This commit is contained in:
Roland Jax
2014-05-14 19:07:47 +02:00
parent 92a3f7fbc5
commit ad200cc6b9
2 changed files with 19 additions and 9 deletions
+13 -3
View File
@@ -78,7 +78,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
case get: case get:
if (cmd.size() < 3) { if (cmd.size() < 3) {
result << "format: type class cmd [sub]"; result << "format: get class cmd (sub)";
break; break;
} }
@@ -120,7 +120,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
case set: case set:
if (cmd.size() != 4) { if (cmd.size() != 4) {
result << "format: type class cmd value"; result << "format: set class cmd value";
break; break;
} }
@@ -173,7 +173,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
case cyc: case cyc:
if (cmd.size() < 3) { if (cmd.size() < 3) {
result << "format: type class cmd [sub]"; result << "format: cyc class cmd (sub)";
break; break;
} }
@@ -200,12 +200,22 @@ std::string BaseLoop::decodeMessage(const std::string& data)
break; break;
case dump: case dump:
if (cmd.size() < 2) {
result << "format: dump on|off";
break;
}
if (cmd[1] == "on") m_ebusloop->dump(true); if (cmd[1] == "on") m_ebusloop->dump(true);
if (cmd[1] == "off") m_ebusloop->dump(false); if (cmd[1] == "off") m_ebusloop->dump(false);
result << "done"; result << "done";
break; break;
case log: case log:
if (cmd.size() < 2) {
result << "format: log error|event|trace|debug";
break;
}
if (cmd[1] == "error") L.getSink(0)->setLevel(error); if (cmd[1] == "error") L.getSink(0)->setLevel(error);
if (cmd[1] == "event") L.getSink(0)->setLevel(event); if (cmd[1] == "event") L.getSink(0)->setLevel(event);
if (cmd[1] == "trace") L.getSink(0)->setLevel(trace); if (cmd[1] == "trace") L.getSink(0)->setLevel(trace);
+6 -6
View File
@@ -84,11 +84,11 @@ void define_args()
"\tlog file name (default: /var/log/ebus-daemon.log)", "\tlog file name (default: /var/log/ebus-daemon.log)",
Appl::type_string, Appl::opt_mandatory); Appl::type_string, Appl::opt_mandatory);
A.addItem("p_area", Appl::Param(all), "", "logarea", A.addItem("p_logarea", Appl::Param(all), "", "logarea",
"\tlogging area (bas=1, net=2, bus=4, cyc=8, default: all=15)", "\tlogging area (bas=1, net=2, bus=4, cyc=8, default: all=15)",
Appl::type_int, Appl::opt_mandatory); Appl::type_int, Appl::opt_mandatory);
A.addItem("p_level", Appl::Param(trace), "", "loglevel", A.addItem("p_loglevel", Appl::Param(trace), "", "loglevel",
"\tlogging level (error=0, event=1, default: trace=2, debug=3)\n", "\tlogging level (error=0, event=1, default: trace=2, debug=3)\n",
Appl::type_int, Appl::opt_mandatory); Appl::type_int, Appl::opt_mandatory);
@@ -196,13 +196,13 @@ int main(int argc, char* argv[])
// make me Daemon // make me Daemon
if (A.getParam<bool>("p_foreground") == true) { if (A.getParam<bool>("p_foreground") == true) {
L += new LogConsole(A.getParam<int>("p_area"), L += new LogConsole(A.getParam<int>("p_logarea"),
static_cast<const Level>(A.getParam<int>("p_level")), static_cast<const Level>(A.getParam<int>("p_loglevel")),
"logConsole"); "logConsole");
} else { } else {
D.run("/var/run/ebus-daemon.pid"); D.run("/var/run/ebus-daemon.pid");
L += new LogFile(A.getParam<int>("p_area"), L += new LogFile(A.getParam<int>("p_logarea"),
static_cast<const Level>(A.getParam<int>("p_level")), static_cast<const Level>(A.getParam<int>("p_loglevel")),
"logFile", A.getParam<const char*>("p_logfile")); "logFile", A.getParam<const char*>("p_logfile"));
} }