summaryrefslogtreecommitdiffstats
path: root/src/Client/CommandParser.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-17 22:18:09 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-17 22:18:09 +0200
commitd84a3b91346038bf55d7111462dab42a0a26445d (patch)
tree1e9eca4eba2a8da8f616815e56385725310fe148 /src/Client/CommandParser.cpp
parentcccc512e2565b7b96b765bfb873f0fb635bd23e1 (diff)
downloadmad-d84a3b91346038bf55d7111462dab42a0a26445d.tar
mad-d84a3b91346038bf55d7111462dab42a0a26445d.zip
Logger f?r Log-Messages benutzen
Diffstat (limited to 'src/Client/CommandParser.cpp')
-rw-r--r--src/Client/CommandParser.cpp19
1 files changed, 10 insertions, 9 deletions
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 <Common/Exception.h>
+#include <Common/Logger.h>
#include <Common/RequestManager.h>
#include <Common/Requests/DisconnectRequest.h>
#include <Net/Packets/HostStatusPacket.h>
@@ -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<std::string> &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<std::string> &args) {
else if(args.size() == 2)
Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(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<Net::Packets
printHostStatus(packet);
}
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();
@@ -198,7 +199,7 @@ void CommandParser::daemonListRequestFinished(const Common::Request<Net::Packets
}
}
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();
@@ -211,7 +212,7 @@ void CommandParser::daemonStatusRequestFinished(const Common::Request<Net::Packe
printHostStatus(packet);
}
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();
@@ -223,7 +224,7 @@ void CommandParser::disconnectRequestFinished(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;
}