cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Static Public Member Functions | Protected Member Functions | List of all members
cmnLogger Class Reference

Class to glue the class register, the output multiplexer and the message level of detail to form the logging entity of cisst. More...

#include <cmnLogger.h>

Public Types

typedef
cmnLODMultiplexerStreambuf
< char > 
StreamBufType
 

Static Public Member Functions

static cmnLoggerInstance (void)
 
static void SetMask (cmnLogMask mask)
 
static void CISST_DEPRECATED SetLoD (cmnLogMask mask)
 
static cmnLogMask GetMask (void)
 
static cmnLogMask CISST_DEPRECATED GetLoD (void)
 
static void SetMaskFunction (cmnLogMask mask)
 
static cmnLogMask GetMaskFunction (void)
 
static bool SetMaskClass (const std::string &className, cmnLogMask mask)
 
static bool SetMaskClassAll (cmnLogMask mask)
 
static bool SetMaskClassMatching (const std::string &stringToMatch, cmnLogMask mask)
 
static StreamBufTypeGetMultiplexer (void)
 
static void HaltDefaultLog (void)
 
static void ResumeDefaultLog (cmnLogMask newLoD=CMN_LOG_ALLOW_DEFAULT)
 
static void SetMaskDefaultLog (cmnLogMask newLoD=CMN_LOG_ALLOW_DEFAULT)
 
static void AddChannel (std::ostream &outputStream, cmnLogMask mask=CMN_LOG_ALLOW_ALL)
 
static void AddChannelToStdOut (cmnLogMask mask=CMN_LOG_ALLOW_ERRORS_AND_WARNINGS)
 
static void AddChannelToStdErr (cmnLogMask mask=CMN_LOG_ALLOW_ERRORS_AND_WARNINGS)
 
static void RemoveChannel (std::ostream &outputStream)
 
static const char * ExtractFileName (const char *file)
 
static void Kill (void)
 

Protected Member Functions

 cmnLogger (const std::string &defaultLogFileName="cisstLog.txt")
 

Detailed Description

Class to glue the class register, the output multiplexer and the message level of detail to form the logging entity of cisst.

cmnLogger is defined as a singleton, i.e. there is only one instance of cmnLogger. This unique object maintains the data required for the cisst logging system. The design of the logging system relies on:

To filter the messages, the user can use:

See Also
cmnClassRegister cmnClassServicesBase cmnLODOutputMultiplexer

Member Typedef Documentation

Type used to define the logging level of detail.

Constructor & Destructor Documentation

cmnLogger::cmnLogger ( const std::string &  defaultLogFileName = "cisstLog.txt")
protected

Constructor. The only constructor must be private in order to ensure that the class register is a singleton.

Member Function Documentation

static void cmnLogger::AddChannel ( std::ostream &  outputStream,
cmnLogMask  mask = CMN_LOG_ALLOW_ALL 
)
inlinestatic

Add an output stream to the logger. The level of detail provided is used to filter the messages, i.e. any message with a level of detail higher than the level associated to the output stream will not be streamed.

static void cmnLogger::AddChannelToStdErr ( cmnLogMask  mask = CMN_LOG_ALLOW_ERRORS_AND_WARNINGS)
inlinestatic

Add std::cerr output stream to the logger. Useful when calling from Python, where redirecting sys.stderr to std::cerr is nontrivial.

static void cmnLogger::AddChannelToStdOut ( cmnLogMask  mask = CMN_LOG_ALLOW_ERRORS_AND_WARNINGS)
inlinestatic

Add std::cout output stream to the logger. Useful when calling from Python, where redirecting sys.stdout to std::cout is nontrivial.

static const char* cmnLogger::ExtractFileName ( const char *  file)
static
static cmnLogMask CISST_DEPRECATED cmnLogger::GetLoD ( void  )
inlinestatic
static cmnLogMask cmnLogger::GetMask ( void  )
inlinestatic

Get the global mask used to filter the log messages.

Returns
The global mask used to filter the log.
See Also
GetMaskInstance
static cmnLogMask cmnLogger::GetMaskFunction ( void  )
inlinestatic

Get the function mask used to filter the log messages.

Returns
The function mask used to filter the log.
See Also
GetMaskInstance
static StreamBufType* cmnLogger::GetMultiplexer ( void  )
inlinestatic

Returns the cmnLODMultiplexerStreambuf directly. This allows manipulation of the streambuffer for operations such as adding or deleting channels for the stream..

Returns
cmnLODMultiplexerStreambuf<char>* The Streambuffer.
See Also
GetMultiplexerInstance
static void cmnLogger::HaltDefaultLog ( void  )
inlinestatic

Disable the default log file "cisstLog.txt". This method removes the default log from the output list of the multiplexer but doesn't close the default log file.

static cmnLogger* cmnLogger::Instance ( void  )
static

The log is instantiated as a singleton. To access the unique instantiation, one needs to use this static method. The instantiated log is created at the first call of this method since it is a static variable declared in this method's scope.

Returns
A pointer to the logger.
static void cmnLogger::Kill ( void  )
inlinestatic

Kill the logger. Set all masks to disable logs and remove all output streams.

static void cmnLogger::RemoveChannel ( std::ostream &  outputStream)
inlinestatic
static void cmnLogger::ResumeDefaultLog ( cmnLogMask  newLoD = CMN_LOG_ALLOW_DEFAULT)
inlinestatic

Resume the default log file. By default, the log is enabled (this is the default behavior of the cmnLogger constructor) but this can be halted by using HaltDefaultLog(). Using ResumeDefaultLog() allows to resume the log to "cisstLog.txt" without losing previous logs.

static void CISST_DEPRECATED cmnLogger::SetLoD ( cmnLogMask  mask)
inlinestatic
static void cmnLogger::SetMask ( cmnLogMask  mask)
inlinestatic

Set the global mask used to filter the log messages.

Parameters
maskThe overall mask used to filter the log.
See Also
SetMaskInstance
static bool cmnLogger::SetMaskClass ( const std::string &  className,
cmnLogMask  mask 
)
static

Specify the log mask for a specific class. See cmnClassRegister::SetLogMaskClass.

Parameters
classNameThe name of the class
maskThe log mask to be applied
Returns
bool True if the class is registered.
static bool cmnLogger::SetMaskClassAll ( cmnLogMask  mask)
static

Specify the log mask for all registered classes. See cmnClassRegister::SetLogMaskClassAll.

Parameters
maskThe log mask to be applied
Returns
bool True if there is at least one class mask was modified
static bool cmnLogger::SetMaskClassMatching ( const std::string &  stringToMatch,
cmnLogMask  mask 
)
static

Specify the log mask for all classes with a name matching a given string. See cmnClassRegister::SetLogMaskClassMatching.

Parameters
stringToMatchA string found in class names (e.g. "cmn")
maskThe log mask to be applied
Returns
bool True if there is at least one class LoD was modified
static void cmnLogger::SetMaskDefaultLog ( cmnLogMask  newLoD = CMN_LOG_ALLOW_DEFAULT)
inlinestatic

Set a new mask for the default log file. This method uses HaltDefaultLog followed by ResumeDefaultLog.

static void cmnLogger::SetMaskFunction ( cmnLogMask  mask)
inlinestatic

Set the "function" mask used to filter the log messages.

Parameters
maskThe function mask used to filter the log.
See Also
SetMaskFunctionInstance

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