LAMA
|
A CommonLogger which adds no prefix to its messages. More...
#include <CommonLogger.hpp>
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< Timer > | mTimer |
Timer used for timings. | |
std::string | mId |
A CommonLogger which adds no prefix to its messages.
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.
level | The 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. |
writeBehaviour | Specifies, 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.
level | The 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. |
writeBehaviour | Specifies, if the logger shall write its output to the console and a file or to the console/file only |
timer | The 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.
level | The 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. |
writeBehaviour | Specifies, if the logger shall write its output to the console and a file or to the console/file only |
logFileName | The 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. |
timer | The timer which shall be used by this logger. |
lama::CommonLogger::~CommonLogger | ( | ) | [virtual] |
Destructor.
std::string lama::CommonLogger::createPrefix | ( | ) | [virtual] |
The CommonLogger adds no prefix to the message, so this method just returns an empty string.
Implements lama::Logger.
References lama::Logger::mId.
LogLevel::LogLevel lama::Logger::getLogLevel | ( | ) | const [inherited] |
Returns the log level of this logger.
References lama::Logger::mLogLevel.
const std::string & lama::Logger::id | ( | ) | const [inherited] |
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)
level | The loglevel of the message. |
message | The message to log. |
References lama::Logger::logString().
Referenced by lama::Logger::logString().
void lama::Logger::logNewLine | ( | LogLevel::LogLevel | level | ) | [inherited] |
Logs an empty line.
level | The 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.
[in] | LogLevel | The LogLevel at which the residual shall be logged. |
[in] | solver | The solver which supplies the residual |
[in] | norm | The Norm used to calculate the residual |
[in] | iterationPrefix | A 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.
[in] | level | The LogLevel to log the string at. |
[in] | message | The 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::logString | ( | const std::string & | message | ) | [protected, virtual, inherited] |
Logs the message.
DOES NOT perform a LogLevel check.
[in] | message | The message to be logged. |
References lama::Logger::createPrefix(), lama::FileLogger::getFileLogger(), lama::FileLogger::logMessage(), lama::Logger::logMessage(), lama::Logger::mWriteBehaviour, lama::LoggerWriteBehaviour::toConsoleOnly, lama::LoggerWriteBehaviour::toFileAndConsole, and lama::LoggerWriteBehaviour::toFileOnly.
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].
[in] | timerId | The ID of the timer whoms time shall be logged. |
[in] | level | The loglevel of the message. |
[in] | message | The message to log. |
References LAMA_ASSERT_DEBUG, lama::Logger::logString(), lama::Logger::mLogLevel, and lama::Logger::mTimer.
void lama::Logger::logType | ( | LogLevel::LogLevel | level, |
const std::string & | message, | ||
T | 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.
[in] | level | The LogLevel |
[in] | message | The message which shall be logged |
[in] | arg | The 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] |
void lama::Logger::startTimer | ( | const std::string & | timerId | ) | [inherited] |
Starts an internal timer of the logger.
Starts the internal timer of the logger.
[in] | timerId | The 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.
[in] | timerId | The 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.
[in] | timerId | The ID of the timer which shall be stopped. |
References LAMA_ASSERT_DEBUG, and lama::Logger::mTimer.
std::string lama::Logger::mId [protected, inherited] |
Referenced by createPrefix(), and lama::Logger::id().
std::auto_ptr<Timer> lama::Logger::mTimer [protected, inherited] |
Timer used for timings.
Referenced by lama::Logger::Logger(), lama::Logger::logTime(), lama::Logger::startTimer(), lama::Logger::stopAndResetTimer(), and lama::Logger::stopTimer().