From d84a3b91346038bf55d7111462dab42a0a26445d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 17 Sep 2008 22:18:09 +0200 Subject: Logger f?r Log-Messages benutzen --- src/Client/CommandParser.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/Client/CommandParser.cpp') diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index 407b9c8..aa203b3 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -22,6 +22,7 @@ #include "Requests/DaemonListRequest.h" #include "Requests/DaemonStatusRequest.h" #include +#include #include #include #include @@ -57,7 +58,7 @@ void CommandParser::printUsage(const std::string& command) { const CommandParser::Command *cmd = findCommand(command); if(cmd) - std::cerr << "Usage: " << cmd->cmdline << std::endl << std::endl; + Common::Logger::log(std::string("Usage: ") + cmd->cmdline + "\n"); } void CommandParser::printHostStatus(const Net::Packets::HostStatusPacket &packet) { @@ -134,10 +135,10 @@ void CommandParser::helpCommand(const std::vector &args) { std::cout << command->longdesc << std::endl << std::endl; } else - std::cerr << args[0] << ": Command '" << args[1] << "' doesn't exist." << std::endl << std::endl; + Common::Logger::log(Common::Logger::WARNING, args[0] + ": Command '" + args[1] + "' doesn't exist.\n"); } else { - std::cerr << args[0] << ": Too many arguments." << std::endl; + Common::Logger::log(Common::Logger::ERROR, args[0] + ": Too many arguments."); printUsage("help"); } } @@ -154,7 +155,7 @@ void CommandParser::statusCommand(const std::vector &args) { else if(args.size() == 2) Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(this, &CommandParser::daemonStatusRequestFinished)))); else { - std::cerr << args[0] << ": Too many arguments." << std::endl; + Common::Logger::log(Common::Logger::ERROR, args[0] + ": Too many arguments."); printUsage("status"); return; } @@ -175,7 +176,7 @@ void CommandParser::coreStatusRequestFinished(const Common::Request &request) disconnect = true; } catch(Common::Exception &exception) { - std::cerr << "An error occurred during your request: " << exception.strerror() << "." << std::endl << std::endl; + Common::Logger::log(Common::Logger::ERROR, std::string("An error occurred during your request: ") + exception.strerror() + ".\n"); } requestFinished(); @@ -299,7 +300,7 @@ bool CommandParser::parse(const std::string &cmd) { if(command) (this->*command->funcPtr)(splitCmd); else - std::cerr << "Unknown command '" << splitCmd[0] << "'." << std::endl << std::endl; + Common::Logger::log(Common::Logger::ERROR, "Unknown command '" + splitCmd[0] + "'.\n"); return true; } -- cgit v1.2.3