LAMA
lama::CommonLogger Class Reference

A CommonLogger which adds no prefix to its messages. More...

#include <CommonLogger.hpp>

Inheritance diagram for lama::CommonLogger:

Public Member Functions

 CommonLogger (const std::string &id, LogLevel::LogLevel level, LoggerWriteBehaviour::LoggerWriteBehaviour writeBehaviour, bool ignoreRank=false)
 Creates a CommonLogger with the specified properties.
 CommonLogger (const std::string &id, LogLevel::LogLevel level, LoggerWriteBehaviour::LoggerWriteBehaviour writeBehaviour, std::auto_ptr< Timer > timer, bool ignoreRank=false)
 Creates a CommonLogger with the specified properties.
 CommonLogger (const std::string &id, LogLevel::LogLevel level, LoggerWriteBehaviour::LoggerWriteBehaviour writeBehaviour, const std::string &logFileName, std::auto_ptr< Timer > timer, bool ignoreRank=false)
 Creates a CommonLogger with the specified properties.
virtual ~CommonLogger ()
 Destructor.
std::string createPrefix ()
 The CommonLogger adds no prefix to the message, so this method just returns an empty string.
const std::string & id () const
 Returns the id of this.
LogLevel::LogLevel getLogLevel () const
 Returns the log level of this logger.
void setLogLevel (LogLevel::LogLevel level)
 Sets the internal LogLevel.
void logMessage (LogLevel::LogLevel level, const std::string &message)
 Logs a user specified message.
void logNewLine (LogLevel::LogLevel level)
 Logs an empty line.
void logResidual (LogLevel::LogLevel level, const Solver &solver, const Norm &norm, const std::string iterationPrefix="")
 Logs the residual of the solver.
void logTime (const std::string &timerId, LogLevel::LogLevel level, const std::string &message)
 logs the elapsed time in combination with a user-specified message.
void startTimer (const std::string &timerId)
 Starts an internal timer of the logger.
void stopTimer (const std::string &timerId)
 Stops an internal timer of the logger.
void stopAndResetTimer (const std::string &timerId)
 Stops and resets an internal timer.
template<typename T >
void logType (LogLevel::LogLevel level, const std::string &message, T arg)
 logs a message followed by an custom type by using the << operator.

Protected Member Functions

virtual void logString (LogLevel::LogLevel level, const std::string &message)
 Performs a LogLevel check and logs the message depending on this.
virtual void logString (const std::string &message)
 Logs the message.
 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Protected Attributes

std::auto_ptr< TimermTimer
 Timer used for timings.
std::string mId

Detailed Description

A CommonLogger which adds no prefix to its messages.


Constructor & Destructor Documentation

lama::CommonLogger::CommonLogger ( const std::string &  id,
LogLevel::LogLevel  level,
LoggerWriteBehaviour::LoggerWriteBehaviour  writeBehaviour,
bool  ignoreRank = false 
)

Creates a CommonLogger with the specified properties.

This constructor creates a CommonLogger with the specified properties.

Parameters:
levelThe loglevel of the logger. Messages with a loglevel greater than the level of the logger will be omitted. Instead of a CommonLogger with the "noLogging" loglevel a NullLogger should be used.
writeBehaviourSpecifies, if the logger shall write its output to the console and a file or to the console/file only
lama::CommonLogger::CommonLogger ( const std::string &  id,
LogLevel::LogLevel  level,
LoggerWriteBehaviour::LoggerWriteBehaviour  writeBehaviour,
std::auto_ptr< Timer timer,
bool  ignoreRank = false 
)

Creates a CommonLogger with the specified properties.

This constructor creates a CommonLogger with the specified properties.

Parameters:
levelThe loglevel of the logger. Messages with a loglevel greater than the level of the logger will be omitted. Instead of a CommonLogger with the "noLogging" loglevel a NullLogger should be used.
writeBehaviourSpecifies, if the logger shall write its output to the console and a file or to the console/file only
timerThe timer which shall be used by this logger.
lama::CommonLogger::CommonLogger ( const std::string &  id,
LogLevel::LogLevel  level,
LoggerWriteBehaviour::LoggerWriteBehaviour  writeBehaviour,
const std::string &  logFileName,
std::auto_ptr< Timer timer,
bool  ignoreRank = false 
)

Creates a CommonLogger with the specified properties.

This constructor creates a CommonLogger with the specified properties.

Parameters:
levelThe loglevel of the logger. Messages with a loglevel greater than the level of the logger will be omitted. Instead of a CommonLogger with the "noLogging" loglevel a NullLogger should be used.
writeBehaviourSpecifies, if the logger shall write its output to the console and a file or to the console/file only
logFileNameThe filename of the file which shall be used by the logger. May throw an exception if a logger with a different filename has been created before.
timerThe timer which shall be used by this logger.

Destructor.


Member Function Documentation

std::string lama::CommonLogger::createPrefix ( ) [virtual]

The CommonLogger adds no prefix to the message, so this method just returns an empty string.

Returns:
The prefix - an empty string.

Implements lama::Logger.

References lama::Logger::mId.

Returns the log level of this logger.

Returns:
The log level of this.

References lama::Logger::mLogLevel.

const std::string & lama::Logger::id ( ) const [inherited]

Returns the id of this.

Returns:
the id of this.

References lama::Logger::mId.

lama::Logger::LAMA_LOG_DECL_STATIC_LOGGER ( logger  ) [protected, inherited]
void lama::Logger::logMessage ( LogLevel::LogLevel  level,
const std::string &  message 
) [inherited]

Logs a user specified message.

This method logs a user specified message (string)

Parameters:
levelThe loglevel of the message.
messageThe message to log.

References lama::Logger::logString().

Referenced by lama::Logger::logString().

void lama::Logger::logNewLine ( LogLevel::LogLevel  level) [inherited]

Logs an empty line.

Parameters:
levelThe LogLevel at which the empty line shall be logged

References lama::Logger::logString().

void lama::Logger::logResidual ( LogLevel::LogLevel  level,
const Solver solver,
const Norm norm,
const std::string  iterationPrefix = "" 
) [inherited]

Logs the residual of the solver.

Parameters:
[in]LogLevelThe LogLevel at which the residual shall be logged.
[in]solverThe solver which supplies the residual
[in]normThe Norm used to calculate the residual
[in]iterationPrefixA Prefix to put in front of the generated log message (Default: "" )

References lama::Solver::getResidual(), lama::Logger::logString(), and lama::Logger::mLogLevel.

void lama::Logger::logString ( LogLevel::LogLevel  level,
const std::string &  message 
) [protected, virtual, inherited]

Performs a LogLevel check and logs the message depending on this.

Parameters:
[in]levelThe LogLevel to log the string at.
[in]messageThe string to be logged.

References lama::Logger::mIgnoreRank, and lama::Logger::mLogLevel.

Referenced by lama::Logger::logMessage(), lama::Logger::logNewLine(), lama::Logger::logResidual(), lama::Logger::logTime(), and lama::Logger::logType().

void lama::Logger::logTime ( const std::string &  timerId,
LogLevel::LogLevel  level,
const std::string &  message 
) [inherited]

logs the elapsed time in combination with a user-specified message.

Logs the elapsed time since the internal timer got started, does not stop the timer. The caller may also specify an additional message. The time and message will be logged in the format [message] [time].

Parameters:
[in]timerIdThe ID of the timer whoms time shall be logged.
[in]levelThe loglevel of the message.
[in]messageThe message to log.

References LAMA_ASSERT_DEBUG, lama::Logger::logString(), lama::Logger::mLogLevel, and lama::Logger::mTimer.

template<typename T >
void lama::Logger::logType ( LogLevel::LogLevel  level,
const std::string &  message,
arg 
) [inherited]

logs a message followed by an custom type by using the << operator.

Example: Can be used to log the number of iterations made by an iterative solver.

Parameters:
[in]levelThe LogLevel
[in]messageThe message which shall be logged
[in]argThe The argument which shall be logged after the message. The << operator must be defined for it!

References lama::Logger::logString(), and lama::Logger::mLogLevel.

void lama::Logger::setLogLevel ( LogLevel::LogLevel  level) [inherited]

Sets the internal LogLevel.

Returns:

References lama::Logger::mLogLevel.

void lama::Logger::startTimer ( const std::string &  timerId) [inherited]

Starts an internal timer of the logger.

Starts the internal timer of the logger.

Parameters:
[in]timerIdThe ID of the timer which shall be started.

References LAMA_ASSERT_DEBUG, and lama::Logger::mTimer.

void lama::Logger::stopAndResetTimer ( const std::string &  timerId) [inherited]

Stops and resets an internal timer.

Stops and resets the internal timer.

Parameters:
[in]timerIdThe ID of the timer which shall be stopped and resetted.

References LAMA_ASSERT_DEBUG, and lama::Logger::mTimer.

void lama::Logger::stopTimer ( const std::string &  timerId) [inherited]

Stops an internal timer of the logger.

Does not reset it.

Stops an internal timer of the logger. Does not reset the timer. The caller may call startTimer() again and the timer will continue to measure the time, beginning with the amount of time it had measured, before the timer got stopped.

Parameters:
[in]timerIdThe ID of the timer which shall be stopped.

References LAMA_ASSERT_DEBUG, and lama::Logger::mTimer.


Field Documentation

std::string lama::Logger::mId [protected, inherited]

Referenced by createPrefix(), and lama::Logger::id().


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