Hi!

This is my first time working on the licq Source, so please bear with me
if I got something wrong.

At the moment (latest CVS) it is no longer possible to disable Debugging
Output with the '-d 0' command line parameter -- this makes the console
plugin nearly unuseable since everything ends up on its screen.

This seems to be caused by log.cpp Revision 1.6 where on line 390 the
whole CLogServer::Log block is replaced by a single call to

CLogServer::Log(S_ALL, _nLogType, _szFormat, argp);

Since Log is called with a ServiceType of 'S_ALL' the check in line 413

if ((*iter)->LogType(_nLogType) || (*iter)->ServiceType() & _nServiceTypes)

is true regardless of the set Debugging Level, and so everything is
logged.

The attached patch reverts the change made by log.cpp Revision 1.6 to
line 390 ff. and copies the changes made to line 403 ff.

I don't know if this is exactly the right thing to do, but it works
here.

Bye, Eike
-- 
Eike Bernhardt              http://unorganized.net/                ICQ: 11256658
"Whatever you do, don't tell anyone!"
                 -- 'The Lost Art of keeping a Secret' - Queens of the Stone Age
Index: src/log.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/log.cpp,v
retrieving revision 1.6
diff -u -r1.6 log.cpp
--- src/log.cpp 11 Feb 2002 22:12:20 -0000      1.6
+++ src/log.cpp 21 Feb 2002 14:08:56 -0000
@@ -387,7 +387,28 @@
 
 void CLogServer::Log(const unsigned short _nLogType, const char *_szFormat, va_list 
argp)
 {
-  CLogServer::Log(S_ALL, _nLogType, _szFormat, argp);
+  static char szTime[32];
+  static struct tm stm;
+  static char szMsgMax[MAX_MSG_SIZE];
+
+  pthread_mutex_lock(&mutex);
+
+  // Create a time string for the log
+  time_t t = time(NULL);
+  localtime_r(&t, &stm);
+  strftime(szTime, 32, "%T: ", &stm);
+
+  vsnprintf(szMsgMax, MAX_MSG_SIZE, _szFormat, argp);
+  szMsgMax[MAX_MSG_SIZE - 1] = '\0';
+
+  // Log the event to each server
+  vector<CLogService *>::iterator iter;
+  for (iter = m_vxLogServices.begin(); iter != m_vxLogServices.end(); iter++)
+  {
+    if ((*iter)->LogType(_nLogType))
+        (*iter)->LogMessage(szTime, szMsgMax, _nLogType);
+  }  
+  pthread_mutex_unlock(&mutex);
 }
 
 void CLogServer::Log(const unsigned short _nServiceTypes, const unsigned short 
_nLogType, const char *_szFormat, va_list argp)

Reply via email to