summaryrefslogtreecommitdiffstats
path: root/src
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
parentcccc512e2565b7b96b765bfb873f0fb635bd23e1 (diff)
downloadmad-d84a3b91346038bf55d7111462dab42a0a26445d.tar
mad-d84a3b91346038bf55d7111462dab42a0a26445d.zip
Logger f?r Log-Messages benutzen
Diffstat (limited to 'src')
-rw-r--r--src/Client/CommandParser.cpp19
-rw-r--r--src/Common/Backends/ConsoleLogger.cpp2
-rw-r--r--src/Common/Backends/ConsoleLogger.h2
-rw-r--r--src/Common/Backends/FileLogger.cpp2
-rw-r--r--src/Common/Backends/FileLogger.h2
-rw-r--r--src/Common/Backends/SystemBackendProc.cpp2
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.cpp5
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.cpp5
-rw-r--r--src/Common/RequestManager.cpp6
-rw-r--r--src/Common/Requests/GSSAPIAuthRequest.cpp9
-rw-r--r--src/Core/ConnectionManager.cpp7
-rw-r--r--src/Core/RequestHandlers/DaemonListRequestHandler.cpp5
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp5
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp7
-rw-r--r--src/Core/RequestHandlers/IdentifyRequestHandler.cpp6
-rw-r--r--src/Net/Listener.cpp2
-rw-r--r--src/mad-core.cpp5
-rw-r--r--src/mad.cpp10
-rw-r--r--src/madc.cpp11
19 files changed, 57 insertions, 55 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;
}
diff --git a/src/Common/Backends/ConsoleLogger.cpp b/src/Common/Backends/ConsoleLogger.cpp
index 180a009..4bfa93b 100644
--- a/src/Common/Backends/ConsoleLogger.cpp
+++ b/src/Common/Backends/ConsoleLogger.cpp
@@ -24,7 +24,7 @@ namespace Mad {
namespace Common {
namespace Backends {
-void ConsoleLogger::logMessage(MessageLevel level, const std::string &message) {
+void ConsoleLogger::logMessage(MessageLevel, const std::string &message) {
std::cerr << message << std::endl;
}
diff --git a/src/Common/Backends/ConsoleLogger.h b/src/Common/Backends/ConsoleLogger.h
index f55d7ba..72fc179 100644
--- a/src/Common/Backends/ConsoleLogger.h
+++ b/src/Common/Backends/ConsoleLogger.h
@@ -28,7 +28,7 @@ namespace Backends {
class ConsoleLogger : public Logger {
protected:
- virtual void logMessage(MessageLevel level, const std::string &message);
+ virtual void logMessage(MessageLevel, const std::string &message);
public:
ConsoleLogger() {}
diff --git a/src/Common/Backends/FileLogger.cpp b/src/Common/Backends/FileLogger.cpp
index 079c08c..b0bd57b 100644
--- a/src/Common/Backends/FileLogger.cpp
+++ b/src/Common/Backends/FileLogger.cpp
@@ -23,7 +23,7 @@ namespace Mad {
namespace Common {
namespace Backends {
-void FileLogger::logMessage(MessageLevel level, const std::string &message) {
+void FileLogger::logMessage(MessageLevel, const std::string &message) {
file << message << std::endl;
}
diff --git a/src/Common/Backends/FileLogger.h b/src/Common/Backends/FileLogger.h
index 219a464..8a72bec 100644
--- a/src/Common/Backends/FileLogger.h
+++ b/src/Common/Backends/FileLogger.h
@@ -32,7 +32,7 @@ class FileLogger : public Logger {
std::ofstream file;
protected:
- virtual void logMessage(MessageLevel level, const std::string &message);
+ virtual void logMessage(MessageLevel, const std::string &message);
public:
FileLogger(const std::string &filename)
diff --git a/src/Common/Backends/SystemBackendProc.cpp b/src/Common/Backends/SystemBackendProc.cpp
index 7e9fcbd..3a3f283 100644
--- a/src/Common/Backends/SystemBackendProc.cpp
+++ b/src/Common/Backends/SystemBackendProc.cpp
@@ -22,8 +22,6 @@
#include <fstream>
#include <pcrecpp.h>
-#include <iostream>
-
namespace Mad {
namespace Common {
namespace Backends {
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
index 010f1e7..6a5ca99 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
@@ -18,18 +18,17 @@
*/
#include "DisconnectRequestHandler.h"
+#include "../Logger.h"
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
-#include <iostream>
-
namespace Mad {
namespace Common {
namespace RequestHandlers {
void DisconnectRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::DISCONNECT) {
- std::cerr << "Received an unexpected packet." << std::endl;
+ Logger::log(Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
signalFinished().emit();
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
index bcff6b6..a3f8675 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.cpp
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -19,19 +19,18 @@
#include "StatusRequestHandler.h"
#include "../SystemBackend.h"
+#include "../Logger.h"
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
#include <Net/Packets/HostStatusPacket.h>
-#include <iostream>
-
namespace Mad {
namespace Common {
namespace RequestHandlers {
void StatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::STATUS) {
- std::cerr << "Received an unexpected packet." << std::endl;
+ Logger::log(Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
signalFinished().emit();
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 2bf82b0..afe72b0 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -20,12 +20,12 @@
#include "RequestManager.h"
#include "Request.h"
#include "RequestHandlers/DisconnectRequestHandler.h"
+#include "Logger.h"
#include <Net/Packets/ErrorPacket.h>
#include <sigc++/bind.h>
#include <sigc++/retype_return.h>
-#include <iostream>
namespace Mad {
namespace Common {
@@ -72,7 +72,7 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
if(it == requestMaps.end()) {
// TODO: Error
- std::cerr << "Received a packet from an unregistered connection." << std::endl;
+ Logger::log(Logger::ERROR, "Received a packet from an unregistered connection.");
return;
}
@@ -95,7 +95,7 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
return;
}
- std::cerr << "Received an unexpected packet." << std::endl;
+ Logger::log(Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Exception(Exception::UNEXPECTED_PACKET)));
}
diff --git a/src/Common/Requests/GSSAPIAuthRequest.cpp b/src/Common/Requests/GSSAPIAuthRequest.cpp
index 53d969f..05fb373 100644
--- a/src/Common/Requests/GSSAPIAuthRequest.cpp
+++ b/src/Common/Requests/GSSAPIAuthRequest.cpp
@@ -18,12 +18,11 @@
*/
#include "GSSAPIAuthRequest.h"
+#include "../Logger.h"
#include <Net/Connection.h>
#include <cstring>
-#include <iostream>
-
namespace Mad {
namespace Common {
namespace Requests {
@@ -58,7 +57,7 @@ void GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t reques
0, GSS_C_NO_CHANNEL_BINDINGS, GSS_C_NO_BUFFER, 0, &buffer, 0, 0);
if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
+ Logger::log(Logger::VERBOSE, "GSS context established.");
gssContinue = false;
}
else if(majStat != GSS_S_CONTINUE_NEEDED) {
@@ -96,7 +95,7 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
std::free(recvBuffer.value);
if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
+ Logger::log(Logger::VERBOSE, "GSS context established.");
gssContinue = false;
}
else if(majStat != GSS_S_CONTINUE_NEEDED) {
@@ -129,7 +128,7 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
return;
connection->setAuthenticated();
- std::cout << "Authentication complete." << std::endl;
+ Logger::log(Logger::VERBOSE, "Authentication complete.");
majStat = gss_delete_sec_context(&minStat, &gssContext, &sendBuffer);
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 2926fbf..3007fd6 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -19,6 +19,7 @@
#include "ConnectionManager.h"
#include "ConfigManager.h"
+#include <Common/Logger.h>
#include <Common/RequestHandlers/StatusRequestHandler.h>
#include "RequestHandlers/DaemonListRequestHandler.h"
#include "RequestHandlers/DaemonStatusRequestHandler.h"
@@ -31,8 +32,6 @@
#include <unistd.h>
#include <algorithm>
-#include <iostream>
-
namespace Mad {
namespace Core {
@@ -190,13 +189,13 @@ void ConnectionManager::identifyDaemonConnection(Net::Connection *connection, co
if(idCon->second) {
idCon->second->disconnect();
- std::cerr << "Disconnecting old connection" << std::endl;
+ Common::Logger::log(Common::Logger::WARNING, "Disconnecting old connection.");
}
idCon->second = *con;
connection->setIdentified();
- std::cerr << "Identified as '" << name << "'." << std::endl;
+ Common::Logger::log("Identified as '" + name + "'.");
}
std::map<std::string,DaemonInfo> ConnectionManager::getDaemonList() const {
diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
index 2bee423..2a6b119 100644
--- a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
@@ -19,19 +19,18 @@
#include "DaemonListRequestHandler.h"
#include "../ConnectionManager.h"
+#include <Common/Logger.h>
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
#include <Net/Packets/NameListPacket.h>
-#include <iostream>
-
namespace Mad {
namespace Core {
namespace RequestHandlers {
void DaemonListRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::LIST_DAEMONS) {
- std::cerr << "Received an unexpected packet." << std::endl;
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
signalFinished().emit();
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
index efdf3ea..7fcf9fe 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
@@ -19,12 +19,11 @@
#include "DaemonStatusRequestHandler.h"
#include "../ConnectionManager.h"
+#include <Common/Logger.h>
#include <Core/Requests/DaemonStatusRequest.h>
#include <Net/Packets/ErrorPacket.h>
#include <Net/Packets/HostStatusPacket.h>
-#include <iostream>
-
namespace Mad {
namespace Core {
@@ -32,7 +31,7 @@ namespace RequestHandlers {
void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::DAEMON_STATUS) {
- std::cerr << "Received an unexpected packet." << std::endl;
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
signalFinished().emit();
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
index d65da7e..e459511 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
@@ -18,13 +18,12 @@
*/
#include "GSSAPIAuthRequestHandler.h"
+#include <Common/Logger.h>
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
#include <cstring>
-#include <iostream>
-
namespace Mad {
namespace Core {
namespace RequestHandlers {
@@ -33,7 +32,7 @@ namespace RequestHandlers {
void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::GSSAPI_AUTH) {
- std::cerr << "Received an unexpected packet." << std::endl;
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
signalFinished().emit();
@@ -55,7 +54,7 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
std::free(recvBuffer.value);
if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
+ Common::Logger::log(Common::Logger::VERBOSE, "GSS context established.");
gssContinue = false;
}
else if(majStat != GSS_S_CONTINUE_NEEDED) {
diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.cpp b/src/Core/RequestHandlers/IdentifyRequestHandler.cpp
index 4e65aca..0d4f25d 100644
--- a/src/Core/RequestHandlers/IdentifyRequestHandler.cpp
+++ b/src/Core/RequestHandlers/IdentifyRequestHandler.cpp
@@ -19,12 +19,10 @@
#include "IdentifyRequestHandler.h"
#include "../ConnectionManager.h"
-#include <Common/Exception.h>
+#include <Common/Logger.h>
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
-#include <iostream>
-
namespace Mad {
namespace Core {
@@ -32,7 +30,7 @@ namespace RequestHandlers {
void IdentifyRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::IDENTIFY) {
- std::cerr << "Received an unexpected packet." << std::endl;
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
signalFinished().emit();
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index 954129a..f470896 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -23,8 +23,6 @@
#include <cstring>
#include <fcntl.h>
-#include <iostream>
-
namespace Mad {
namespace Net {
diff --git a/src/mad-core.cpp b/src/mad-core.cpp
index ddc1414..40c3654 100644
--- a/src/mad-core.cpp
+++ b/src/mad-core.cpp
@@ -17,6 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Common/Logger.h"
+#include "Common/Backends/ConsoleLogger.h"
#include "Net/Connection.h"
#include "Core/ConnectionManager.h"
#include "Core/ConfigManager.h"
@@ -29,6 +31,9 @@ int main() {
sigaddset(&signals, SIGPIPE);
sigprocmask(SIG_BLOCK, &signals, 0);
+ Mad::Common::Backends::ConsoleLogger logger;
+ Mad::Common::Logger::registerLogger(&logger);
+
Mad::Core::ConfigManager::useConfigManager();
Mad::Core::ConnectionManager::init();
diff --git a/src/mad.cpp b/src/mad.cpp
index b2f8b61..0985bb0 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -20,20 +20,24 @@
#include "Net/ClientConnection.h"
#include "Net/IPAddress.h"
#include "Common/Backends/SystemBackendProc.h"
+#include "Common/Logger.h"
+#include "Common/Backends/ConsoleLogger.h"
#include "Common/Request.h"
#include "Common/RequestManager.h"
#include "Common/RequestHandlers/StatusRequestHandler.h"
#include "Daemon/Requests/IdentifyRequest.h"
-#include <iostream>
#include <unistd.h>
void requestFinished(const Mad::Common::Request<>&) {
- std::cerr << "Identified." << std::endl;
+ Mad::Common::Logger::log("Identified.");
}
int main() {
+ Mad::Common::Backends::ConsoleLogger logger;
+ Mad::Common::Logger::registerLogger(&logger);
+
Mad::Net::Connection::init();
Mad::Common::RequestManager::init(false);
@@ -70,7 +74,7 @@ int main() {
Mad::Common::RequestManager::getRequestManager()->unregisterConnection(connection);
}
catch(Mad::Net::Exception &e) {
- std::cerr << "Connection error: " << e.what() << std::endl;
+ Mad::Common::Logger::log(Mad::Common::Logger::CRITICAL, "Connection error: " + e.what());
}
delete connection;
diff --git a/src/madc.cpp b/src/madc.cpp
index 12a190e..66e235d 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -19,6 +19,8 @@
#include "Net/ClientConnection.h"
#include "Net/IPAddress.h"
+#include "Common/Logger.h"
+#include "Common/Backends/ConsoleLogger.h"
#include "Common/RequestManager.h"
#include "Common/Util.h"
#include "Client/CommandParser.h"
@@ -70,6 +72,9 @@ int main(int argc, char *argv[]) {
std::exit(1);
}
+ Mad::Common::Backends::ConsoleLogger logger;
+ Mad::Common::Logger::registerLogger(&logger);
+
Mad::Net::Connection::init();
Mad::Common::RequestManager::init(false);
@@ -78,7 +83,7 @@ int main(int argc, char *argv[]) {
try {
connection->connect(Mad::Net::IPAddress(argv[1]));
- std::cout << "Connecting to " << argv[1] << "..." << std::flush;
+ std::cerr << "Connecting to " << argv[1] << "..." << std::flush;
while(connection->isConnecting()) {
struct pollfd fd = connection->getPollfd();
@@ -87,7 +92,7 @@ int main(int argc, char *argv[]) {
connection->sendReceive(fd.revents);
}
- std::cout << " connected." << std::endl << std::endl;
+ std::cerr << " connected." << std::endl << std::endl;
Mad::Common::RequestManager::getRequestManager()->registerConnection(connection);
@@ -114,7 +119,7 @@ int main(int argc, char *argv[]) {
Mad::Common::RequestManager::getRequestManager()->unregisterConnection(connection);
}
catch(Mad::Net::Exception &e) {
- std::cerr << "Connection error: " << e.what() << std::endl;
+ Mad::Common::Logger::log(Mad::Common::Logger::CRITICAL, "Connection error: " + e.what());
}
delete connection;