diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-12-20 21:08:00 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-12-20 21:08:00 +0000 |
commit | c390ec7befcfeeda8504bdd74eb823b7ab721bf3 (patch) | |
tree | ad1c0164748a96ea5cb0a9b546585b7dd1c371f2 /src/connectionhandler.cpp | |
parent | 609d235de3435fdc768207e59a2ee85172f291ba (diff) | |
download | manaserv-c390ec7befcfeeda8504bdd74eb823b7ab721bf3.tar.gz manaserv-c390ec7befcfeeda8504bdd74eb823b7ab721bf3.tar.bz2 manaserv-c390ec7befcfeeda8504bdd74eb823b7ab721bf3.tar.xz manaserv-c390ec7befcfeeda8504bdd74eb823b7ab721bf3.zip |
Adding command line argument parsing and log verbosity level handling.
Diffstat (limited to 'src/connectionhandler.cpp')
-rw-r--r-- | src/connectionhandler.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp index 52186187..c8ed1c6e 100644 --- a/src/connectionhandler.cpp +++ b/src/connectionhandler.cpp @@ -103,13 +103,13 @@ ConnectionHandler::startListen(ListenThreadData *ltd) // Allocate a socket set SDLNet_SocketSet set = SDLNet_AllocSocketSet(MAX_CLIENTS); if (!set) { - LOG_FATAL("SDLNet_AllocSocketSet: " << SDLNet_GetError()) + LOG_FATAL("SDLNet_AllocSocketSet: " << SDLNet_GetError(), 0) exit(1); } // Add the server socket to the socket set if (SDLNet_TCP_AddSocket(set, ltd->socket) < 0) { - LOG_FATAL("SDLNet_AddSocket: " << SDLNet_GetError()) + LOG_FATAL("SDLNet_AddSocket: " << SDLNet_GetError(), 0) exit(1); } @@ -118,12 +118,12 @@ ConnectionHandler::startListen(ListenThreadData *ltd) int numready = SDLNet_CheckSockets(set, 100); if (numready == -1) { - LOG_ERROR("SDLNet_CheckSockets: " << SDLNet_GetError()) + LOG_ERROR("SDLNet_CheckSockets: " << SDLNet_GetError(), 0) // When this is a system error, perror may help us perror("SDLNet_CheckSockets"); } else if (numready > 0) { - LOG_INFO(numready << " sockets with activity!") + LOG_INFO(numready << " sockets with activity!", 0) // Check server socket if (SDLNet_SocketReady(ltd->socket)) { @@ -132,13 +132,13 @@ ConnectionHandler::startListen(ListenThreadData *ltd) if (client) { // Add the client socket to the socket set if (SDLNet_TCP_AddSocket(set, client) < 0) { - LOG_ERROR("SDLNet_AddSocket: " << SDLNet_GetError()) + LOG_ERROR("SDLNet_AddSocket: " << SDLNet_GetError(), 0) } else { NetComputer *comp = new NetComputer(this, client); clients.push_back(comp); computerConnected(comp); - LOG_INFO(clients.size() << " client(s) connected") + LOG_INFO(clients.size() << " client(s) connected", 0) } } } @@ -168,10 +168,7 @@ ConnectionHandler::startListen(ListenThreadData *ltd) //buffer[result] = 0; //LOG_INFO("Received: " << buffer << ", Length: " // << result); - - - LOG_INFO("Received length: " - << result); + LOG_INFO("Received length: " << result, 2); #ifdef SCRIPT_SUPPORT // This could be good if you wanted to extend the @@ -207,11 +204,11 @@ ConnectionHandler::startListen(ListenThreadData *ltd) else { // bad message (no registered handler) LOG_ERROR("Unhandled message (" << messageId - << ") received from " << ipaddr); + << ") received from " << ipaddr, 0); } } else { - LOG_ERROR("Message too short from " << ipaddr); + LOG_ERROR("Message too short from " << ipaddr, 0); } } } @@ -234,12 +231,12 @@ ConnectionHandler::startListen(ListenThreadData *ltd) void ConnectionHandler::computerConnected(NetComputer *comp) { - LOG_INFO("A client connected!") + LOG_INFO("A client connected!", 0) } void ConnectionHandler::computerDisconnected(NetComputer *comp) { - LOG_INFO("A client disconnected!") + LOG_INFO("A client disconnected!", 0) } void ConnectionHandler::registerHandler( |