NLMISC::CLog Class Reference

#include <log.h>

Inheritance diagram for NLMISC::CLog:

NLNET::CNetLog

Detailed Description

When display() is called, the logger builds a string a sends it to its attached displayers. The positive filters, if any, are applied first, then the negative filters. See the nldebug/nlinfo... macros in debug.h.

log_howto

Todo:
cado: display() and displayRaw() should save the string and send it only when displayRawNL() (or a flush()-style method) is called.
Author:
Vianney Lecroart, Olivier Cado

Nevrax France

Date:
2001

Definition at line 54 of file log.h.

Public Types

enum  TLogType {
  LOG_NO = 0, LOG_ERROR, LOG_WARNING, LOG_INFO,
  LOG_DEBUG, LOG_STAT, LOG_ASSERT, LOG_UNKNOWN
}

Public Member Functions

void addDisplayer (IDisplayer *displayer, bool bypassFilter=false)
void addNegativeFilter (const char *filterstr)
 Adds a negative filter. Tells the logger to discard the lines that contain filterstr.

void addPositiveFilter (const char *filterstr)
 Adds a positive filter. Tells the logger to log only the lines that contain filterstr.

bool attached (IDisplayer *displayer) const
 Returns true if the specified displayer is attached to the log object.

 CLog (TLogType logType=LOG_NO)
void display (const char *format,...)
 Display a string in decorated form to all attached displayers. Call setPosition() before. Releases the mutex.

void displayFilter (CLog &log)
 Displays the list of filter into a log.

void displayNL (const char *format,...)
 Display a string in decorated and final new line form to all attached displayers. Call setPosition() before. Releases the mutex.

void displayRaw (const char *format,...)
 Display a string (and nothing more) to all attached displayers. Call setPosition() before. Releases the mutex.

void displayRawNL (const char *format,...)
 Display a string with a final new line to all attached displayers. Call setPosition() before. Releases the mutex.

void forceDisplayRaw (const char *format,...)
IDisplayergetDisplayer (const char *displayerName)
 Return the first displayer selected by his name.

bool noDisplayer () const
 Returns true if no displayer is attached.

void removeDisplayer (const char *displayerName)
 Remove a displayer using his name.

void removeDisplayer (IDisplayer *displayer)
 Remove a displayer. If the displayer doesn't work in a specific time, you could remove it.

void removeFilter (const char *filterstr=NULL)
 Removes a filter by name (in both filters).

void resetFilters ()
 Reset both filters.

void setPosition (sint line, char *fileName)
 If !noDisplayer(), sets line and file parameters, and enters the mutex. If !noDisplayer(), don't forget to call display...() after, to release the mutex.


Static Public Member Functions

void setDefaultProcessName ()
 Find the process name if nobody call setProcessName before.

void setProcessName (const std::string &processName)
 Set the name of the process.


Protected Types

typedef std::list< IDisplayer * > CDisplayers

Protected Member Functions

void displayRawString (const char *str)
 Display a Raw string to all attached displayers.

void displayString (const char *str)
 Display a string in decorated form to all attached displayers.

bool passFilter (const char *filter)
 Returns true if the string must be logged, according to the current filter.

void unsetPosition ()
 Symetric to setPosition(). Automatically called by display...(). Do not call if noDisplayer().


Protected Attributes

CDisplayers _BypassFilterDisplayers
CDisplayers _Displayers
char * _FileName
sint _Line
TLogType _LogType
CMutex _Mutex
std::list< std::string > _NegativeFilter
 "Discard" filter

std::list< std::string > _PositiveFilter
 "Crop" filter

uint32 _PosSet
TDisplayInfo TempArgs
std::string TempString

Static Protected Attributes

std::string * _ProcessName = NULL


Member Typedef Documentation

typedef std::list<IDisplayer *> NLMISC::CLog::CDisplayers [protected]
 

Definition at line 209 of file log.h.


Member Enumeration Documentation

enum NLMISC::CLog::TLogType
 

Enumeration values:
LOG_NO 
LOG_ERROR 
LOG_WARNING 
LOG_INFO 
LOG_DEBUG 
LOG_STAT 
LOG_ASSERT 
LOG_UNKNOWN 

Definition at line 57 of file log.h.


Constructor & Destructor Documentation

NLMISC::CLog::CLog TLogType  logType = LOG_NO  ) 
 

Definition at line 51 of file log.cpp.

References LOG, NLMISC::toString(), and uint.

00051                             : _LogType (logType), _Line(-1), _FileName(NULL), _Mutex("LOG"+toString((uint)logType)), _PosSet(false)
00052 {
00053 }


Member Function Documentation

void NLMISC::CLog::addDisplayer IDisplayer displayer,
bool  bypassFilter = false
 

Add a new displayer in the log. You have to create the displayer, remove it and delete it when you have finish with it. For example, in a 3dDisplayer, you can add the displayer when you want, and the displayer displays the string if the 3d screen is available and do nothing otherwise. In this case, if you want, you could leave the displayer all the time.

Definition at line 115 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

Referenced by NLMISC::initDebug2(), NLNET::IService::main(), NLNET::serviceGetView(), and NLNET::updateAdmin().

00116 {
00117         if (displayer == NULL)
00118         {
00119                 // Can't nlwarning because recursive call
00120                 printf ("Trying to add a NULL displayer\n");
00121                 return;
00122         }
00123 
00124         if (bypassFilter)
00125         {
00126                 CDisplayers::iterator idi = std::find (_BypassFilterDisplayers.begin (), _BypassFilterDisplayers.end (), displayer);
00127                 if (idi == _BypassFilterDisplayers.end ())
00128                 {
00129                         _BypassFilterDisplayers.push_back (displayer);
00130                 }
00131                 else
00132                 {
00133                         nlwarning ("LOG: Couldn't add the displayer, it was already added");
00134                 }
00135         }
00136         else
00137         {
00138                 CDisplayers::iterator idi = std::find (_Displayers.begin (), _Displayers.end (), displayer);
00139                 if (idi == _Displayers.end ())
00140                 {
00141                         _Displayers.push_back (displayer);
00142                 }
00143                 else
00144                 {
00145                         nlwarning ("LOG: Couldn't add the displayer, it was already added");
00146                 }
00147         }
00148 }

void NLMISC::CLog::addNegativeFilter const char *  filterstr  ) 
 

Adds a negative filter. Tells the logger to discard the lines that contain filterstr.

Definition at line 593 of file log.cpp.

References _NegativeFilter.

Referenced by NLNET::cbLogFilter(), and NLMISC::NLMISC_COMMAND().

00594 {
00595         //displayNL ("CLog::addNegativeFilter('%s')", filterstr);
00596         _NegativeFilter.push_back( filterstr );
00597 }

void NLMISC::CLog::addPositiveFilter const char *  filterstr  ) 
 

Adds a positive filter. Tells the logger to log only the lines that contain filterstr.

Definition at line 587 of file log.cpp.

References _PositiveFilter.

Referenced by NLMISC::NLMISC_COMMAND().

00588 {
00589         //displayNL ("CLog::addPositiveFilter('%s')", filterstr);
00590         _PositiveFilter.push_back( filterstr );
00591 }

bool NLMISC::CLog::attached IDisplayer displayer  )  const
 

Returns true if the specified displayer is attached to the log object.

Definition at line 235 of file log.cpp.

References _BypassFilterDisplayers, and _Displayers.

00236 {
00237         return (find( _Displayers.begin(), _Displayers.end(), displayer ) != _Displayers.end()) ||
00238                         (find( _BypassFilterDisplayers.begin(), _BypassFilterDisplayers.end(), displayer ) != _BypassFilterDisplayers.end());
00239 }

void NLMISC::CLog::display const char *  format,
... 
 

Display a string in decorated form to all attached displayers. Call setPosition() before. Releases the mutex.

Definition at line 348 of file log.cpp.

References format, and NLMISC_CONVERT_VARGS.

Referenced by NLMISC::CBufFIFO::display().

00350 {
00351         if ( noDisplayer() )
00352         {
00353                 return;
00354         }
00355 
00356         char *str;
00357         NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
00358 
00359         displayString (str);
00360 }

void NLMISC::CLog::displayFilter CLog log  ) 
 

Displays the list of filter into a log.

Definition at line 572 of file log.cpp.

References _NegativeFilter, _PositiveFilter, and displayNL().

Referenced by NLMISC::NLMISC_COMMAND().

00573 {
00574         std::list<std::string>::iterator it;
00575         log.displayNL ("Positive Filter(s):");
00576         for (it = _PositiveFilter.begin (); it != _PositiveFilter.end (); it++)
00577         {
00578                 log.displayNL ("'%s'", (*it).c_str());
00579         }
00580         log.displayNL ("Negative Filter(s):");
00581         for (it = _NegativeFilter.begin (); it != _NegativeFilter.end (); it++)
00582         {
00583                 log.displayNL ("'%s'", (*it).c_str());
00584         }
00585 }

void NLMISC::CLog::displayNL const char *  format,
... 
 

Display a string in decorated and final new line form to all attached displayers. Call setPosition() before. Releases the mutex.

Definition at line 323 of file log.cpp.

References format, and NLMISC_CONVERT_VARGS.

Referenced by NLNET::createMessage(), NLNET::CUnifiedNetwork::CUnifiedConnection::display(), NLMISC::CHTimer::display(), NLMISC::displayCallStack(), displayFilter(), NLMISC::CHTimer::displayHierarchical(), NLNET::CUnifiedNetwork::displayInternalTables(), NLMISC::CBufFIFO::displayStats(), NLMISC::CBitMemStream::displayStream(), NLNET::CBufServer::displayThreadStat(), NLNET::CBufClient::displayThreadStat(), NLMISC::CVariable< std::string >::execute(), NLMISC::IVariable::execute(), NLMISC::ICommand::execute(), NLMISC::ICommand::expand(), NLMISC::CEntityIdTranslator::isValidEntityName(), and NLNET::IService::main().

00325 {
00326         if ( noDisplayer() )
00327         {
00328                 return;
00329         }
00330 
00331         char *str;
00332         NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
00333 
00334         if (strlen(str)<256/*NLMISC::MaxCStringSize*/-1)
00335                 strcat (str, "\n");
00336         else
00337                 str[256/*NLMISC::MaxCStringSize*/-2] = '\n';
00338 
00339         displayString (str);
00340 }

void NLMISC::CLog::displayRaw const char *  format,
... 
 

Display a string (and nothing more) to all attached displayers. Call setPosition() before. Releases the mutex.

Definition at line 467 of file log.cpp.

References format, and NLMISC_CONVERT_VARGS.

Referenced by NLNET::cleanRequest(), and NLMISC::CConfigFile::display().

00469 {
00470         if ( noDisplayer() )
00471         {
00472                 return;
00473         }
00474 
00475         char *str;
00476         NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
00477 
00478         displayRawString(str);
00479 }

void NLMISC::CLog::displayRawNL const char *  format,
... 
 

Display a string with a final new line to all attached displayers. Call setPosition() before. Releases the mutex.

Definition at line 442 of file log.cpp.

References format, and NLMISC_CONVERT_VARGS.

Referenced by NLNET::cleanRequest(), NLMISC::CHTimer::CStats::display(), NLMISC::CHTimer::display(), NLMISC::CConfigFile::display(), NLMISC::CHTimer::displayByExecutionPath(), NLMISC::displayByteBits(), NLMISC::displayDwordBits(), NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), NLMISC::CHTimer::CNode::displayPath(), NLMISC::CBitMemStream::displayStream(), NLMISC::CHTimer::displaySummary(), NLNET::CNetLog::input(), and NLNET::CNetLog::output().

00444 {
00445         if ( noDisplayer() )
00446         {
00447                 return;
00448         }
00449 
00450         char *str;
00451         NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
00452 
00453         if (strlen(str)<256/*NLMISC::MaxCStringSize*/-1)
00454                 strcat (str, "\n");
00455         else
00456                 str[256/*NLMISC::MaxCStringSize*/-2] = '\n';
00457 
00458         displayRawString(str);
00459 }

void NLMISC::CLog::displayRawString const char *  str  )  [protected]
 

Display a Raw string to all attached displayers.

Definition at line 362 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, NLMISC::CLog::TDisplayInfo::CallstackAndLog, NLMISC::CLog::TDisplayInfo::Date, NLMISC::CLog::TDisplayInfo::Filename, NLMISC::getCallStackAndLog(), NLMISC::CLog::TDisplayInfo::Line, LOG_ASSERT, LOG_ERROR, NLMISC::CLog::TDisplayInfo::LogType, passFilter(), NLMISC::CLog::TDisplayInfo::ProcessName, setDefaultProcessName(), TempArgs, TempString, NLMISC::CLog::TDisplayInfo::ThreadId, and unsetPosition().

00363 {
00364         const char *disp = NULL;
00365         TDisplayInfo localargs, *args = NULL;
00366 
00367         setDefaultProcessName ();
00368 
00369         if(strchr(str,'\n') == NULL)
00370         {
00371                 if (TempString.empty())
00372                 {
00373                         localargs.Date = 0;
00374                         localargs.LogType = CLog::LOG_NO;
00375                         localargs.ProcessName = "";
00376                         localargs.ThreadId = 0;
00377                         localargs.Filename = NULL;
00378                         localargs.Line = -1;
00379                         localargs.CallstackAndLog = "";
00380 
00381                         TempString = str;
00382                 }
00383                 else
00384                 {
00385                         TempString += str;
00386                 }
00387                 return;
00388         }
00389         else
00390         {
00391                 if (TempString.empty())
00392                 {
00393                         localargs.Date = 0;
00394                         localargs.LogType = CLog::LOG_NO;
00395                         localargs.ProcessName = "";
00396                         localargs.ThreadId = 0;
00397                         localargs.Filename = NULL;
00398                         localargs.Line = -1;
00399                         localargs.CallstackAndLog = "";
00400 
00401                         disp = str;
00402                         args = &localargs;
00403                 }
00404                 else
00405                 {
00406                         TempString += str;
00407                         disp = TempString.c_str();
00408                         args = &TempArgs;
00409                 }
00410         }
00411 
00412         // send to all bypass filter displayers
00413         for (CDisplayers::iterator idi=_BypassFilterDisplayers.begin(); idi!=_BypassFilterDisplayers.end(); idi++ )
00414         {
00415                 (*idi)->display( *args, disp );
00416         }
00417 
00418         // get the log at the last minute to be sure to have everything
00419         if(args->LogType == LOG_ERROR || args->LogType == LOG_ASSERT)
00420         {
00421                 getCallStackAndLog (args->CallstackAndLog, 4);
00422         }
00423 
00424         if ( passFilter( disp ) )
00425         {
00426                 // Send to the attached displayers
00427                 for ( CDisplayers::iterator idi=_Displayers.begin(); idi!=_Displayers.end(); idi++ )
00428                 {
00429                         (*idi)->display( *args, disp );
00430                 }
00431         }
00432         TempString = "";
00433         unsetPosition();
00434 }

void NLMISC::CLog::displayString const char *  str  )  [protected]
 

Display a string in decorated form to all attached displayers.

Definition at line 242 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, _LogType, _ProcessName, NLMISC::CLog::TDisplayInfo::CallstackAndLog, NLMISC::CLog::TDisplayInfo::Date, NLMISC::CLog::TDisplayInfo::Filename, NLMISC::getCallStackAndLog(), NLMISC::getThreadId(), NLMISC::CLog::TDisplayInfo::Line, LOG_ASSERT, LOG_ERROR, NLMISC::CLog::TDisplayInfo::LogType, passFilter(), NLMISC::CLog::TDisplayInfo::ProcessName, setDefaultProcessName(), TempArgs, TempString, NLMISC::CLog::TDisplayInfo::ThreadId, and unsetPosition().

00243 {
00244         const char *disp = NULL;
00245         TDisplayInfo localargs, *args = NULL;
00246 
00247         setDefaultProcessName ();
00248 
00249         if(strchr(str,'\n') == NULL)
00250         {
00251                 if (TempString.empty())
00252                 {
00253                         time (&TempArgs.Date);
00254                         TempArgs.LogType = _LogType;
00255                         TempArgs.ProcessName = *_ProcessName;
00256                         TempArgs.ThreadId = getThreadId();
00257                         TempArgs.Filename = _FileName;
00258                         TempArgs.Line = _Line;
00259                         TempArgs.CallstackAndLog = "";
00260 
00261                         TempString = str;
00262                 }
00263                 else
00264                 {
00265                         TempString += str;
00266                 }
00267                 return;
00268         }
00269         else
00270         {
00271                 if (TempString.empty())
00272                 {
00273                         time (&localargs.Date);
00274                         localargs.LogType = _LogType;
00275                         localargs.ProcessName = *_ProcessName;
00276                         localargs.ThreadId = getThreadId();
00277                         localargs.Filename = _FileName;
00278                         localargs.Line = _Line;
00279                         localargs.CallstackAndLog = "";
00280 
00281                         disp = str;
00282                         args = &localargs;
00283                 }
00284                 else
00285                 {
00286                         TempString += str;
00287                         disp = TempString.c_str();
00288                         args = &TempArgs;
00289                 }
00290         }
00291 
00292         // send to all bypass filter displayers
00293         for (CDisplayers::iterator idi=_BypassFilterDisplayers.begin(); idi!=_BypassFilterDisplayers.end(); idi++ )
00294         {
00295                 (*idi)->display( *args, disp );
00296         }
00297 
00298         // get the log at the last minute to be sure to have everything
00299         if(args->LogType == LOG_ERROR || args->LogType == LOG_ASSERT)
00300         {
00301                 getCallStackAndLog (args->CallstackAndLog, 4);
00302         }
00303 
00304         if (passFilter (disp))
00305         {
00306                 // Send to the attached displayers
00307                 for (CDisplayers::iterator idi=_Displayers.begin(); idi!=_Displayers.end(); idi++ )
00308                 {
00309                         (*idi)->display( *args, disp );
00310                 }
00311         }
00312         TempString = "";
00313         unsetPosition();
00314 }

void NLMISC::CLog::forceDisplayRaw const char *  format,
... 
 

Display a raw text to the normal displayer but without filtering It's used by the Memdisplayer (little hack to work)

Definition at line 485 of file log.cpp.

References format, and NLMISC_CONVERT_VARGS.

Referenced by NLMISC::CMemDisplayer::write().

00487 {
00488         if ( noDisplayer() )
00489         {
00490                 return;
00491         }
00492 
00493         char *str;
00494         NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
00495 
00496         TDisplayInfo args;
00497         CDisplayers::iterator idi;
00498 
00499         // send to all bypass filter displayers
00500         for (idi=_BypassFilterDisplayers.begin(); idi!=_BypassFilterDisplayers.end(); idi++ )
00501         {
00502                 (*idi)->display( args, str );
00503         }
00504 
00505         // Send to the attached displayers
00506         for ( idi=_Displayers.begin(); idi!=_Displayers.end(); idi++ )
00507         {
00508                 (*idi)->display( args, str );
00509         }
00510 }

IDisplayer * NLMISC::CLog::getDisplayer const char *  displayerName  ) 
 

Return the first displayer selected by his name.

Definition at line 206 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

00207 {
00208         if (displayerName == NULL || displayerName[0] == '\0')
00209         {
00210                 nlwarning ("LOG: Trying to get an empty displayer name");
00211                 return NULL;
00212         }
00213 
00214         CDisplayers::iterator idi;
00215         for (idi = _Displayers.begin (); idi != _Displayers.end (); idi++)
00216         {
00217                 if ((*idi)->DisplayerName == displayerName)
00218                 {
00219                         return *idi;
00220                 }
00221         }
00222         for (idi = _BypassFilterDisplayers.begin (); idi != _BypassFilterDisplayers.end (); idi++)
00223         {
00224                 if ((*idi)->DisplayerName == displayerName)
00225                 {
00226                         return *idi;
00227                 }
00228         }
00229         return NULL;
00230 }

bool NLMISC::CLog::noDisplayer  )  const [inline]
 

Returns true if no displayer is attached.

Definition at line 95 of file log.h.

References _BypassFilterDisplayers, and _Displayers.

Referenced by setPosition(), and unsetPosition().

00095 { return _Displayers.empty() && _BypassFilterDisplayers.empty(); }

bool NLMISC::CLog::passFilter const char *  filter  )  [protected]
 

Returns true if the string must be logged, according to the current filter.

Definition at line 517 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

Referenced by displayRawString(), and displayString().

00518 {
00519         bool yes = _PositiveFilter.empty();
00520 
00521         bool found;
00522         list<string>::iterator ilf;
00523 
00524         // 1. Positive filter
00525         for ( ilf=_PositiveFilter.begin(); ilf!=_PositiveFilter.end(); ++ilf )
00526         {
00527                 found = ( strstr( filter, (*ilf).c_str() ) != NULL );
00528                 if ( found )
00529                 {
00530                         yes = true; // positive filter passed (no need to check another one)
00531                         break;
00532                 }
00533                 // else try the next one
00534         }
00535         if ( ! yes )
00536         {
00537                 return false; // positive filter not passed
00538         }
00539 
00540         // 2. Negative filter
00541         for ( ilf=_NegativeFilter.begin(); ilf!=_NegativeFilter.end(); ++ilf )
00542         {
00543                 found = ( strstr( filter, (*ilf).c_str() ) != NULL );
00544                 if ( found )
00545                 {
00546                         return false; // negative filter not passed (no need to check another one)
00547                 }
00548         }
00549         return true; // negative filter passed
00550 }

void NLMISC::CLog::removeDisplayer const char *  displayerName  ) 
 

Remove a displayer using his name.

Definition at line 172 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

00173 {
00174         if (displayerName == NULL || displayerName[0] == '\0')
00175         {
00176                 nlwarning ("LOG: Trying to remove an empty displayer name");
00177                 return;
00178         }
00179 
00180         CDisplayers::iterator idi;
00181         for (idi = _Displayers.begin (); idi != _Displayers.end ();)
00182         {
00183                 if ((*idi)->DisplayerName == displayerName)
00184                 {
00185                         idi = _Displayers.erase (idi);
00186                 }
00187                 else
00188                 {
00189                         idi++;
00190                 }
00191         }
00192 
00193         for (idi = _BypassFilterDisplayers.begin (); idi != _BypassFilterDisplayers.end ();)
00194         {
00195                 if ((*idi)->DisplayerName == displayerName)
00196                 {
00197                         idi = _BypassFilterDisplayers.erase (idi);
00198                 }
00199                 else
00200                 {
00201                         idi++;
00202                 }
00203         }
00204 }

void NLMISC::CLog::removeDisplayer IDisplayer displayer  ) 
 

Remove a displayer. If the displayer doesn't work in a specific time, you could remove it.

Definition at line 150 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

Referenced by NLNET::IService::main().

00151 {
00152         if (displayer == NULL)
00153         {
00154                 nlwarning ("LOG: Trying to remove a NULL displayer");
00155                 return;
00156         }
00157 
00158         CDisplayers::iterator idi = std::find (_Displayers.begin (), _Displayers.end (), displayer);
00159         if (idi != _Displayers.end ())
00160         {
00161                 _Displayers.erase (idi);
00162         }
00163 
00164         idi = std::find (_BypassFilterDisplayers.begin (), _BypassFilterDisplayers.end (), displayer);
00165         if (idi != _BypassFilterDisplayers.end ())
00166         {
00167                 _BypassFilterDisplayers.erase (idi);
00168         }
00169 
00170 }

void NLMISC::CLog::removeFilter const char *  filterstr = NULL  ) 
 

Removes a filter by name (in both filters).

Definition at line 556 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

Referenced by NLNET::cbLogFilter(), and NLMISC::NLMISC_COMMAND().

00557 {
00558         if (filterstr == NULL)
00559         {
00560                 _PositiveFilter.clear();
00561                 _NegativeFilter.clear();
00562                 //displayNL ("CLog::addNegativeFilter('%s')", filterstr);
00563         }
00564         else
00565         {
00566                 _PositiveFilter.remove( filterstr );
00567                 _NegativeFilter.remove( filterstr );
00568                 //displayNL ("CLog::removeFilter('%s')", filterstr);
00569         }
00570 }

void NLMISC::CLog::resetFilters  ) 
 

Reset both filters.

Definition at line 599 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

Referenced by NLMISC::NLMISC_COMMAND().

00600 {
00601         //displayNL ("CLog::resetFilter()");
00602         _PositiveFilter.clear();
00603         _NegativeFilter.clear();
00604 }

void NLMISC::CLog::setDefaultProcessName  )  [static]
 

Find the process name if nobody call setProcessName before.

Definition at line 55 of file log.cpp.

References _ProcessName.

Referenced by displayRawString(), and displayString().

00056 {
00057         if (_ProcessName == NULL)
00058         {
00059 #undef new
00060                 _ProcessName = new string;
00061 #define new NL_NEW
00062         }
00063 
00064 #ifdef NL_OS_WINDOWS
00065         if ((*_ProcessName).empty())
00066         {
00067                 char name[1024];
00068                 GetModuleFileName (NULL, name, 1023);
00069                 (*_ProcessName) = CFile::getFilename(name);
00070         }
00071 #else
00072         if ((*_ProcessName).empty())
00073         {
00074                 *_ProcessName = "<Unknown>";
00075         }
00076 #endif
00077 }

void NLMISC::CLog::setPosition sint  line,
char *  fileName
 

If !noDisplayer(), sets line and file parameters, and enters the mutex. If !noDisplayer(), don't forget to call display...() after, to release the mutex.

Definition at line 89 of file log.cpp.

References _PosSet, noDisplayer(), and sint.

00090 {
00091         if ( !noDisplayer() )
00092         {
00093                 _Mutex.enter();
00094                 _PosSet++;
00095             _Line = line;
00096                 _FileName = filename;
00097         }
00098 }

void NLMISC::CLog::setProcessName const std::string &  processName  )  [static]
 

Set the name of the process.

Definition at line 79 of file log.cpp.

References _ProcessName.

Referenced by NLNET::IService::main().

00080 {
00081         if (_ProcessName == NULL)
00082         {
00083                 _ProcessName = new string;
00084         }
00085 
00086         *_ProcessName = processName;
00087 }

void NLMISC::CLog::unsetPosition  )  [protected]
 

Symetric to setPosition(). Automatically called by display...(). Do not call if noDisplayer().

Definition at line 101 of file log.cpp.

References _PosSet, nlassert, and noDisplayer().

Referenced by displayRawString(), and displayString().

00102 {
00103         nlassert( !noDisplayer() );
00104 
00105         if ( _PosSet > 0 )
00106         {
00107                 _FileName = NULL;
00108                 _Line = -1;
00109                 _PosSet--;
00110                 _Mutex.leave(); // needs setPosition() to have been called
00111         }
00112 }


Field Documentation

CDisplayers NLMISC::CLog::_BypassFilterDisplayers [protected]
 

Definition at line 213 of file log.h.

Referenced by addDisplayer(), attached(), displayRawString(), displayString(), getDisplayer(), noDisplayer(), and removeDisplayer().

CDisplayers NLMISC::CLog::_Displayers [protected]
 

Definition at line 211 of file log.h.

Referenced by addDisplayer(), attached(), displayRawString(), displayString(), getDisplayer(), noDisplayer(), and removeDisplayer().

char* NLMISC::CLog::_FileName [protected]
 

Definition at line 207 of file log.h.

sint NLMISC::CLog::_Line [protected]
 

Definition at line 206 of file log.h.

TLogType NLMISC::CLog::_LogType [protected]
 

Definition at line 203 of file log.h.

Referenced by displayString().

CMutex NLMISC::CLog::_Mutex [protected]
 

Definition at line 215 of file log.h.

std::list<std::string> NLMISC::CLog::_NegativeFilter [protected]
 

"Discard" filter

Definition at line 220 of file log.h.

Referenced by addNegativeFilter(), displayFilter(), passFilter(), removeFilter(), and resetFilters().

std::list<std::string> NLMISC::CLog::_PositiveFilter [protected]
 

"Crop" filter

Definition at line 223 of file log.h.

Referenced by addPositiveFilter(), displayFilter(), passFilter(), removeFilter(), and resetFilters().

uint32 NLMISC::CLog::_PosSet [protected]
 

Definition at line 217 of file log.h.

Referenced by setPosition(), and unsetPosition().

string * NLMISC::CLog::_ProcessName = NULL [static, protected]
 

Definition at line 49 of file log.cpp.

Referenced by displayString(), setDefaultProcessName(), and setProcessName().

TDisplayInfo NLMISC::CLog::TempArgs [protected]
 

Definition at line 232 of file log.h.

Referenced by displayRawString(), and displayString().

std::string NLMISC::CLog::TempString [protected]
 

Definition at line 231 of file log.h.

Referenced by displayRawString(), and displayString().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:21:01 2004 for NeL by doxygen 1.3.6