summaryrefslogtreecommitdiffstats
path: root/src/Client
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client')
-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;
}