Index: /branches/network/src/lib/network/Makefile.am
===================================================================
--- /branches/network/src/lib/network/Makefile.am	(revision 7747)
+++ /branches/network/src/lib/network/Makefile.am	(revision 7748)
@@ -21,4 +21,5 @@
 		      converter.cc \
 		      message_manager.cc \
+		      network_log.cc \
 		      \
 		      synchronizeable_var/synchronizeable_var.cc \
@@ -52,4 +53,5 @@
 		 netdefs.h \
 		 message_manager.h \
+		 network_log.h \
 		 \
 		 synchronizeable_var/synchronizeable_var.h \
Index: /branches/network/src/lib/network/data_stream.cc
===================================================================
--- /branches/network/src/lib/network/data_stream.cc	(revision 7747)
+++ /branches/network/src/lib/network/data_stream.cc	(revision 7748)
@@ -16,6 +16,4 @@
 /* include Data_stream Header */
 #include "data_stream.h"
-
-
 
 
Index: /branches/network/src/lib/network/network_log.cc
===================================================================
--- /branches/network/src/lib/network/network_log.cc	(revision 7748)
+++ /branches/network/src/lib/network/network_log.cc	(revision 7748)
@@ -0,0 +1,217 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+#include "network_log.h"
+
+/**
+ *  the singleton reference to this class
+ */
+NetworkLog* NetworkLog::singletonRef = NULL;
+
+
+/**
+ * standard constructor
+ */
+NetworkLog::NetworkLog ()
+{
+  listensock = NULL;
+}
+
+
+/**
+   @brief standard deconstructor
+ */
+NetworkLog::~NetworkLog ()
+{
+  NetworkLog::singletonRef = NULL;
+}
+
+/**
+ * listens on port for connections
+ * @param port port number
+ * @return true on success
+ */
+bool NetworkLog::listen( int port )
+{
+  IPaddress ip;
+
+  if ( SDLNet_ResolveHost( &ip, NULL, port ) == -1 ) {
+    PRINT(1)( "SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
+    listensock = NULL;
+    return false;
+  }
+  
+  listensock = SDLNet_TCP_Open( &ip );
+  
+  if( !listensock ) {
+    PRINT(1)( "SDLNet_TCP_Open: %s\n", SDLNet_GetError() );
+    return false;
+  } 
+
+  return true;
+}
+
+/**
+ * prints string to all connected sockets
+ */
+void NetworkLog::printfn( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+ 
+  printfnet();
+}
+
+/**
+ * accepts new connections
+ */
+void NetworkLog::acceptNewConnections( )
+{
+  TCPsocket newSock = SDLNet_TCP_Accept( listensock );
+  
+  if ( newSock )
+    sockets.push_back( newSock );
+}
+
+/**
+ * prints to all connected sockets and to PRINTF(0)
+ */
+void NetworkLog::printf0( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+  
+  PRINT(0)( buf );
+  printfnet();
+
+}
+
+/**
+ * prints to all connected sockets and to PRINTF(1)
+ */
+void NetworkLog::printf1( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+  
+  PRINT(1)( buf );
+  printfnet();
+
+}
+
+/**
+ * prints to all connected sockets and to PRINTF(2)
+ */
+void NetworkLog::printf2( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+  
+  PRINT(2)( buf );
+  printfnet();
+
+}
+
+/**
+ * prints to all connected sockets and to PRINTF(3)
+ */
+void NetworkLog::printf3( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+  
+  PRINT(3)( buf );
+  printfnet();
+
+}
+
+/**
+ * prints to all connected sockets and to PRINTF(4)
+ */
+void NetworkLog::printf4( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+  
+  PRINT(4)( buf );
+  printfnet();
+
+}
+
+/**
+ * prints to all connected sockets and to PRINTF(5)
+ */
+void NetworkLog::printf5( char * format, ... )
+{
+  va_list ap;
+  va_start( ap, format );
+  
+  assert( vsnprintf( buf, NETWORK_LOG_BUFLEN, format, ap ) < NETWORK_LOG_BUFLEN );
+  
+  va_end( ap );
+  
+  PRINT(5)( buf );
+  printfnet();
+
+}
+
+
+/**
+ * prints buf to network sockets
+ */
+void NetworkLog::printfnet()
+{
+  if ( !listensock )
+    return;
+  
+  acceptNewConnections();
+
+  for ( std::list<TCPsocket>::iterator it = sockets.begin(); it != sockets.end(); )
+  {
+    if ( SDLNet_TCP_Send( *it, buf, strlen( buf) ) < strlen( buf ) )
+    {
+      std::list<TCPsocket>::iterator delIt = it;
+      it++;
+      sockets.erase( delIt );
+      continue;
+    }
+    
+    it++;
+  }
+}
Index: /branches/network/src/lib/network/network_log.h
===================================================================
--- /branches/network/src/lib/network/network_log.h	(revision 7748)
+++ /branches/network/src/lib/network/network_log.h	(revision 7748)
@@ -0,0 +1,63 @@
+/*!
+ * @file network_log.h
+ * @brief Definition of the NetworkLog singleton Class
+ */
+
+#ifndef _NETWORK_LOG_H
+#define _NETWORK_LOG_H
+
+#include "netdefs.h"
+#include "debug.h"
+#include "SDL_net.h"
+
+#include <string>
+#include <list>
+
+#define NETWORK_LOG_BUFLEN 1024
+
+/* macro definitions */
+#define NETPRINTF(x) NETPRINTF ## x
+
+#define NETPRINTFn NetworkLog::getInstance()->printfn("%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printfn
+#define NETPRINTF0 NetworkLog::getInstance()->printf0("%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf0
+#define NETPRINTF1 NetworkLog::getInstance()->printf1("(EE)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf1
+#define NETPRINTF2 NetworkLog::getInstance()->printf2("(WW)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf2
+#define NETPRINTF3 NetworkLog::getInstance()->printf3("(II)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf3
+#define NETPRINTF4 NetworkLog::getInstance()->printf4("(DD)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf4
+#define NETPRINTF5 NetworkLog::getInstance()->printf5("(VD)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf5
+
+//! A default singleton class.
+class NetworkLog
+{
+
+  public:
+    virtual ~NetworkLog(void);
+    /** @returns a Pointer to the only object of this Class */
+    inline static NetworkLog* getInstance(void) { if (!singletonRef) singletonRef = new NetworkLog();  return singletonRef; };
+    
+    bool listen( int port );
+    
+    void printfnet( );
+    
+    void printfn( char * format, ... );
+    void printf0( char * format, ... );
+    void printf1( char * format, ... );
+    void printf2( char * format, ... );
+    void printf3( char * format, ... );
+    void printf4( char * format, ... );
+    void printf5( char * format, ... );
+
+  private:
+    NetworkLog();
+    
+    void acceptNewConnections();
+    
+    static NetworkLog* singletonRef;
+    
+    TCPsocket listensock;
+    std::list<TCPsocket> sockets;
+    
+    char buf[NETWORK_LOG_BUFLEN];
+};
+
+#endif /* _NETWORK_LOG_H */
Index: /branches/network/src/lib/network/network_stream.cc
===================================================================
--- /branches/network/src/lib/network/network_stream.cc	(revision 7747)
+++ /branches/network/src/lib/network/network_stream.cc	(revision 7748)
@@ -30,4 +30,7 @@
 #include "shared_network_data.h"
 #include "message_manager.h"
+
+#include "network_log.h"
+
 
 #include "lib/util/loading/factory.h"
@@ -582,5 +585,5 @@
         peer->second.ping /= peer->second.ackDelay.size();
       
-      PRINTF(0)("PING: user: %d ping: %d\n", peer->second.userId, peer->second.ping );
+      NETPRINTF(0)("PING: user: %d ping: %d\n", peer->second.userId, peer->second.ping );
     
       peer->second.lastAckedState = ackedState;
Index: /branches/network/src/subprojects/network/network_unit_test.cc
===================================================================
--- /branches/network/src/subprojects/network/network_unit_test.cc	(revision 7747)
+++ /branches/network/src/subprojects/network/network_unit_test.cc	(revision 7748)
@@ -17,4 +17,5 @@
 #include "shared_network_data.h"
 #include "message_manager.h"
+#include "network_log.h"
 
 #include "simple_sync.h"
@@ -265,4 +266,6 @@
   SimpleSync* ss = new SimpleSync("Server");
   ss->setSynchronized( true );
+  
+  NetworkLog::getInstance()->listen( 8888 );
 
   //MessageManager::getInstance()->initUser( 1 );
