/*! * @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 #include #define NETWORK_LOG_BUFLEN 1024 /* macro definitions */ #define NETPRINTF(x) NETPRINTF ## x #define NETPRINT(x) NETPRINT ## 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 #define NETPRINTn NetworkLog::getInstance()->printfn #define NETPRINT0 NetworkLog::getInstance()->printf0 #define NETPRINT1 NetworkLog::getInstance()->printf1 #define NETPRINT2 NetworkLog::getInstance()->printf2 #define NETPRINT3 NetworkLog::getInstance()->printf3 #define NETPRINT4 NetworkLog::getInstance()->printf4 #define NETPRINT5 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 sockets; char buf[NETWORK_LOG_BUFLEN]; }; #endif /* _NETWORK_LOG_H */