From 0c3c3fa8ae69e75b5adf7210891bdd32c7bd64de Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 3 Sep 2006 09:49:15 +0000 Subject: [PATCH] better logging capabilities --- src/channel.cpp | 12 ++++++------ src/server.cpp | 6 +++--- src/util.h | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 368b1980..8b7df30a 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -298,7 +298,7 @@ void CChannel::SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut ) void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact ) { // TEST -qDebug ( "new network block size factor: %d", iNewNetwBlSiFact ); +//qDebug ( "new network block size factor: %d", iNewNetwBlSiFact ); SetNetwBufSizeFactOut ( iNewNetwBlSiFact ); } @@ -340,7 +340,7 @@ void CChannel::SetSockBufSize ( const int iNumBlocks ) void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) { // TEST -qDebug ( "new jitter buffer size: %d", iNewJitBufSize ); +//qDebug ( "new jitter buffer size: %d", iNewJitBufSize ); SetSockBufSize ( iNewJitBufSize ); } @@ -447,10 +447,10 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) { // inform other objects that new connection was established if ( bNewConnection ) { - -// TEST debug output -CHostAddress address ( GetAddress() ); -qDebug ( "new connection with IP %s", address.InetAddr.toString().latin1() ); + // log new connection + CHostAddress address ( GetAddress() ); + qDebug ( CLogTimeDate::toString() + "Connected with IP %s", + address.InetAddr.toString().latin1() ); emit NewConnection(); } diff --git a/src/server.cpp b/src/server.cpp index 9ceae680..aceb7dcf 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -27,7 +27,7 @@ /* Implementation *************************************************************/ CServer::CServer () : Socket ( &ChannelSet, this ) -{ +{ vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES ); /* init moving average buffer for response time evaluation */ @@ -73,7 +73,7 @@ void CServer::Start () /* init time for response time evaluation */ TimeLastBlock = QTime::currentTime (); - qDebug("Server started"); + qDebug ( CLogTimeDate::toString() + "Server started" ); } } @@ -82,7 +82,7 @@ void CServer::Stop () /* stop main timer */ Timer.stop (); - qDebug("Server stopped"); + qDebug ( CLogTimeDate::toString() + "Server stopped" ); } void CServer::OnTimer () diff --git a/src/util.h b/src/util.h index 01f04b13..0e28fb30 100755 --- a/src/util.h +++ b/src/util.h @@ -436,6 +436,24 @@ public: ); } }; + + +/* Time and Data to String conversion --------------------------------------- */ +class CLogTimeDate +{ +public: + static QString toString() + { + const QDateTime curDateTime = QDateTime::currentDateTime(); + + // format date and time output according to "3.9.2006 11:38:08: " + return QString().setNum ( curDateTime.date().day() ) + "." + + QString().setNum ( curDateTime.date().month() ) + "." + + QString().setNum ( curDateTime.date().year() ) + " " + + curDateTime.time().toString() + ": "; + } +}; + #endif /* !defined(UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_) */