diff options
Diffstat (limited to 'rotord/rotord.cpp')
| -rwxr-xr-x | rotord/rotord.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index 77725ff..6f2d765 100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -14,7 +14,7 @@ void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe std::ostream& ostr = response.send(); - ostr << "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; + ostr << "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; //this is the mysterious extra header ostr << content; } @@ -22,12 +22,12 @@ void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){ - Logger& logger = Logger::get("Rotor"); Poco::URI theuri=Poco::URI(request.getURI()); std::vector <std::string> command; theuri.getPathSegments(command); + Logger& logger = Logger::get("Rotor"); logger.information(request.clientAddress().toString()+" "+request.getMethod()); HTTPResponse::HTTPStatus status=HTTPResponse::HTTP_BAD_REQUEST; //by default @@ -52,7 +52,7 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS //Throws a SystemException if no MAC address can be obtained. // //seems to hang, to me - logger.information("Rotor: starting thread "+sID); + logger.information("starting thread "+sID); manager.start(new Rotor::Render_context(sID)); //XML.addTag("sID"); XML.addValue("sID",sID); @@ -64,12 +64,13 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS bool found=false; for (auto& task: manager.taskList()) { if(task->name()==sID) { + logger.error("ERROR: tried to create thread with existing name "+sID); XML.addValue("error","Render context /"+sID+"/ exists already"); found=true; } } if (!found){ - cerr << "Rotor: starting thread "<< sID << endl; + logger.information("starting thread "+sID); manager.start(new Rotor::Render_context(sID)); XML.addValue("sID",sID); status=HTTPResponse::HTTP_OK; @@ -80,6 +81,7 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS else if (command[0]=="list") { XML.pushTag("rotor"); if (request.getMethod()=="GET") { + logger.information("sending tasklist"); //std::list < Poco::AutoPtr < Poco::Task > >::iterator it; //it=manager.taskList().begin(); //for (it=manager.taskList().begin();it !=manager.taskList().end();++it) { @@ -97,6 +99,7 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS } } else if (command[0]=="exit") { + logger.information("exiting"); exit(0); } else { @@ -112,9 +115,11 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS if (request.getMethod()=="DELETE") { task->cancel(); status=HTTPResponse::HTTP_OK; + logger.information("deleted context "+command[0]); XML.addValue("status","context deleted successfully"); } else { + logger.error("ERROR: Render context invoked with no command: "+command[0]); XML.addValue("error","Render context invoked with no command"); } } @@ -138,13 +143,15 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS } if (!found) { status=HTTPResponse::HTTP_NOT_FOUND; + logger.error("ERROR: context not found: "+command[0]); XML.pushTag("rotor"); XML.addValue("error","Render context not found"); } } } else { - XML.addValue("error","Emoty request"); + logger.error("ERROR: Empty request"); + XML.addValue("error","Empty request"); } string content; XML.copyXmlToString(content); |
