# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CLog Class Reference

When display() is called, the logger builds a string a sends it to its attached displayers. More...

#include <log.h>

Inheritance diagram for NLMISC::CLog:

NLNET::CNetLog List of all members.

Public Types

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

Public Methods

 CLog (TLogType logType=LOG_NO)
void 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. More...

IDisplayergetDisplayer (const char *displayerName)
 Return the first displayer selected by his name. More...

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

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

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

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

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. More...

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. More...

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

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

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

void 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). More...

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

void addNegativeFilter (const char *filterstr)
 Adds a negative filter. Tells the logger to discard the lines that contain filterstr. More...

void resetFilters ()
 Reset both filters. More...

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

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


Static Public Methods

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

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


Protected Types

typedef std::list< IDisplayer * > CDisplayers

Protected Methods

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

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

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

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


Protected Attributes

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

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


Static Protected Attributes

std::string _ProcessName = ""

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.

How to log information (for debugging purpose) ?

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 53 of file log.h.


Member Typedef Documentation

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

Definition at line 136 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 56 of file log.h.


Constructor & Destructor Documentation

NLMISC::CLog::CLog TLogType    logType = LOG_NO
 

Definition at line 51 of file log.cpp.

References uint.


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 98 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

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

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

Definition at line 581 of file log.cpp.

References _NegativeFilter.

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 575 of file log.cpp.

References _PositiveFilter.

bool NLMISC::CLog::attached IDisplayer   displayer const
 

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

Definition at line 217 of file log.cpp.

References _BypassFilterDisplayers, and _Displayers.

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 326 of file log.cpp.

References displayString, format, NLMISC_CONVERT_VARGS, and noDisplayer.

void NLMISC::CLog::displayFilter CLog &    log
 

Displays the list of filter into a log.

Definition at line 560 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

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 305 of file log.cpp.

References displayString, format, NLMISC_CONVERT_VARGS, and noDisplayer.

Referenced by NLNET::CUnifiedNetwork::displayInternalTables, NLMISC::CVariable::execute, and NLMISC::ICommand::expand.

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 displayRawString, format, NLMISC_CONVERT_VARGS, and noDisplayer.

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 446 of file log.cpp.

References displayRawString, format, NLMISC_CONVERT_VARGS, and noDisplayer.

Referenced by NLNET::CNetLog::input, and NLNET::CNetLog::output.

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

Display a Raw string to all attached displayers.

Definition at line 369 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, _FileName, _Line, _LogType, _ProcessName, NLMISC::getCallStackAndLog, NLMISC::getThreadId, LOG_ASSERT, LOG_ERROR, passFilter, setDefaultProcessName, NLMISC::TempArgs, NLMISC::TempString, and unsetPosition.

Referenced by displayRaw, and displayRawNL.

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

Display a string in decorated form to all attached displayers.

Definition at line 227 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, _FileName, _Line, _LogType, _ProcessName, NLMISC::getCallStackAndLog, NLMISC::getThreadId, LOG_ASSERT, LOG_ERROR, passFilter, setDefaultProcessName, NLMISC::TempArgs, NLMISC::TempString, and unsetPosition.

Referenced by display, and displayNL.

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 481 of file log.cpp.

References _Displayers, format, NLMISC_CONVERT_VARGS, and noDisplayer.

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

Return the first displayer selected by his name.

Definition at line 188 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

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

Returns true if no displayer is attached.

Definition at line 78 of file log.h.

References _BypassFilterDisplayers, and _Displayers.

Referenced by display, displayNL, displayRaw, displayRawNL, forceDisplayRaw, setPosition, and unsetPosition.

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

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

Definition at line 505 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

Referenced by displayRawString, and displayString.

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

Remove a displayer using his name.

Definition at line 154 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

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 132 of file log.cpp.

References _BypassFilterDisplayers, _Displayers, and nlwarning.

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

Removes a filter by name (in both filters).

Definition at line 544 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

void NLMISC::CLog::resetFilters  
 

Reset both filters.

Definition at line 587 of file log.cpp.

References _NegativeFilter, and _PositiveFilter.

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.

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 72 of file log.cpp.

References _FileName, _Line, _Mutex, _PosSet, noDisplayer, and sint.

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

Set the name of the process.

Definition at line 67 of file log.cpp.

References _ProcessName.

void NLMISC::CLog::unsetPosition   [protected]
 

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

Definition at line 84 of file log.cpp.

References _FileName, _Line, _Mutex, _PosSet, nlassert, and noDisplayer.

Referenced by displayRawString, and displayString.


Member Data Documentation

CDisplayers NLMISC::CLog::_BypassFilterDisplayers [protected]
 

Definition at line 140 of file log.h.

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

CDisplayers NLMISC::CLog::_Displayers [protected]
 

Definition at line 138 of file log.h.

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

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

Definition at line 134 of file log.h.

Referenced by displayRawString, displayString, setPosition, and unsetPosition.

sint NLMISC::CLog::_Line [protected]
 

Definition at line 133 of file log.h.

Referenced by displayRawString, displayString, setPosition, and unsetPosition.

TLogType NLMISC::CLog::_LogType [protected]
 

Definition at line 130 of file log.h.

Referenced by displayRawString, and displayString.

CMutex NLMISC::CLog::_Mutex [protected]
 

Definition at line 142 of file log.h.

Referenced by setPosition, and unsetPosition.

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

"Discard" filter.

Definition at line 147 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 150 of file log.h.

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

uint32 NLMISC::CLog::_PosSet [protected]
 

Definition at line 144 of file log.h.

Referenced by setPosition, and unsetPosition.

string NLMISC::CLog::_ProcessName = "" [static, protected]
 

Definition at line 49 of file log.cpp.

Referenced by displayRawString, displayString, NLNET::CNetLog::input, NLNET::CNetLog::output, setDefaultProcessName, and setProcessName.


The documentation for this class was generated from the following files: