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/madc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/madc.cpp') 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; -- cgit v1.2.3