IBAMR  IBAMR version 0.19.
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SAMRAI::tbox::Logger Class Reference

#include <tbox/Logger.h>

Classes

class  Appender
 

Public Member Functions

void logAbort (const std::string &message, const std::string &filename, const int line)
 
void logWarning (const std::string &message, const std::string &filename, const int line)
 
void logDebug (const std::string &message, const std::string &filename, const int line)
 
void setAbortAppender (tbox::Pointer< Appender > appender)
 
void setWarningAppender (tbox::Pointer< Appender > appender)
 
void setDebugAppender (tbox::Pointer< Appender > appender)
 
void setWarning (bool onoff)
 
void setDebug (bool onoff)
 

Static Public Member Functions

static LoggergetInstance ()
 
static void free ()
 

Private Member Functions

 Logger ()
 
 ~Logger ()
 

Private Attributes

tbox::Pointer< Appenderd_abort_appender
 
tbox::Pointer< Appenderd_warning_appender
 
tbox::Pointer< Appenderd_debug_appender
 
bool d_log_warning
 
bool d_log_debug
 

Static Private Attributes

static Loggers_instance
 

Detailed Description

Logger is a Singleton class for logging error, debug, and warning messages.

The logAbort, logWarning, and logDebug methods are used to log a message coming from a file and line.

Warning and Debug messages can be turned on/off using the setWarning and setDebug methods. Abort messages may not be turned off.

Applications may override the logging mechanism.The basic idea is the singleton Logger directs log messages to the appropriate Appender which is responsible for writing the log message. The Appender is the destination for the log message. Users may supply implementors of the Appender interface to log the messages to different I/O streams or elsewhere. In this way applications can redirect SAMRAI generated messages to that applications logging mechanism. Appenders may be provided for abort, warning, and/or debug messages. The same Appender may be used for all messages.

For example to log to a stream simply inherit from LoggerAppender and implement the logMesage method:

class StreamAppender : public tbox::Logger::Appender {
public:
StreamAppender(ostream *stream) {
d_stream = stream;
}
void logMessage(const std::string &message,
const std::string &filename,
const int line)
{
(*d_stream) << "At :" << filename << " line :" << line
<< " message: " << message << std::endl;
}
private:
ostream *d_stream;
};

This Appender could be use to log warning message using: tbox::Pointer<tbox::Logger::Appender> appender = new ConsoleAppender() tbox::Logger.getInstance() -> setWarningAppender(appender);

Normally this would be done at the start of an application.

Constructor & Destructor Documentation

◆ Logger()

SAMRAI::tbox::Logger::Logger ( )
private

◆ ~Logger()

SAMRAI::tbox::Logger::~Logger ( )
private

Member Function Documentation

◆ getInstance()

static Logger* SAMRAI::tbox::Logger::getInstance ( )
static

Gets the instance of the singleton logger.

◆ free()

static void SAMRAI::tbox::Logger::free ( )
static

Frees instance of the singleton logger.

NOTE: should be called by ShutdownRegistry only.

◆ logAbort()

void SAMRAI::tbox::Logger::logAbort ( const std::string &  message,
const std::string &  filename,
const int  line 
)

Logs an abort message with file & location

◆ logWarning()

void SAMRAI::tbox::Logger::logWarning ( const std::string &  message,
const std::string &  filename,
const int  line 
)

Logs warning message with file & location.

◆ logDebug()

void SAMRAI::tbox::Logger::logDebug ( const std::string &  message,
const std::string &  filename,
const int  line 
)

Logs debug message with file & location.

◆ setAbortAppender()

void SAMRAI::tbox::Logger::setAbortAppender ( tbox::Pointer< Appender appender)

Set the Appender for logging abort messages to an application specific class.

Default is to log to perr.

◆ setWarningAppender()

void SAMRAI::tbox::Logger::setWarningAppender ( tbox::Pointer< Appender appender)

Set the Appender for logging warning messages to an application specific class.

Default is to log to plog.

◆ setDebugAppender()

void SAMRAI::tbox::Logger::setDebugAppender ( tbox::Pointer< Appender appender)

Set the Appender for logging debug messages to an application specific class.

Default is to log to plog.

◆ setWarning()

void SAMRAI::tbox::Logger::setWarning ( bool  onoff)

Turn logging of warning messages on or off.

Default is on.

◆ setDebug()

void SAMRAI::tbox::Logger::setDebug ( bool  onoff)

Turn logging of debug messages on or off.

Default is off.

Member Data Documentation

◆ s_instance

Logger* SAMRAI::tbox::Logger::s_instance
staticprivate

◆ d_abort_appender

tbox::Pointer<Appender> SAMRAI::tbox::Logger::d_abort_appender
private

◆ d_warning_appender

tbox::Pointer<Appender> SAMRAI::tbox::Logger::d_warning_appender
private

◆ d_debug_appender

tbox::Pointer<Appender> SAMRAI::tbox::Logger::d_debug_appender
private

◆ d_log_warning

bool SAMRAI::tbox::Logger::d_log_warning
private

◆ d_log_debug

bool SAMRAI::tbox::Logger::d_log_debug
private

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