X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FtestServer.cc;h=e8123e26bb028345b0edcb7122c637e8e09f3b29;hb=1863c038d0400159ce49b851a5b81c2ce698c684;hp=0ede86578de137a3de1cb87c1d2d71d1ea54a759;hpb=9cda1b12a3e68538ea8157ca96810f0423123a70;p=senf.git diff --git a/Console/testServer.cc b/Console/testServer.cc index 0ede865..e8123e2 100644 --- a/Console/testServer.cc +++ b/Console/testServer.cc @@ -69,33 +69,51 @@ void shutdownServer() throw senf::console::Executor::ExitException(); } +void enableLogging(std::ostream & os) +{ + senf::console::Client::get(os).route(); +} + int main(int, char **) { - senf::log::ConsoleTarget::instance().route< senf::SenfLog, senf::log::NOTICE >(); + ::signal(SIGPIPE, SIG_IGN); + senf::log::ConsoleTarget::instance().route< senf::log::VERBOSE >(); senf::console::root() .doc("This is the console test application"); + senf::console::root() - .mkdir("network") - .doc("Network related settings"); - senf::console::root()["network"] - .mkdir("eth0") - .doc("Ethernet device eth0"); + .mkdir("console") + .doc("Console settings"); + + senf::console::DirectoryNode & serverDir ( + senf::console::root() + .mkdir("server") + .doc("server commands") ); + + senf::console::ScopedDirectory<> testDir; senf::console::root() - .mkdir("server"); - senf::console::root()["server"] + .add("test", testDir) + .doc("Test functions"); + + senf::console::root()["console"] + .add("showlog", &enableLogging) + .doc("Enable display of log messages on the current console"); + + serverDir .add("shutdown", &shutdownServer) .doc("Terminate server application"); - senf::console::root()["network"] + + testDir .add("echo", &echo) .doc("Example of a function utilizing manual argument parsing"); TestObject test; - senf::console::root() + testDir .add("testob", test.dir) .doc("Example of an instance directory"); - senf::console::Server::start( senf::INet4SocketAddress(23232) ) + senf::console::Server::start( senf::INet4SocketAddress(23232u) ) .name("testServer"); senf::Scheduler::instance().process();