![]() |
Implementation of a logger class.The Logger class represents the core of the logging functionality. It is responsible for commiting logging messages immediately to the according log file(s). The logger works for both serial as well as MPI parallel environments. In case of a non-MPI-parallel simulation the Logger creates the log file 'blaze.log', which contains all logging information from all logging levels. In case of a MPI parallel simulation, each process creates his own individual log file called 'blazeX.log', where 'X' is replaced by the according rank the process has in the MPI_COMM_WORLD communicator.
Note that the log file(s) are only created in case any logging information is created. This might for instance result in only a small number of log file(s) in MPI parallel simulations when only some of the processes encounter errors/warnings/etc.
Note that the logging functionality may not be used before MPI_Init() has been finished. In consequence, this means that no global data that is initialized before the main() function may contain any use of the logging functionality!
More...
#include <Logger.h>
Inherits blaze::Singleton< Logger, SystemClock >.
Public Member Functions | |
Destructor | |
~Logger () | |
Destructor for the Logger class. More... | |
Private Types | |
typedef Singleton< Logger, SystemClock, NullType, NullType, NullType, NullType, NullType, NullType, NullType > | SingletonType |
Type of this Singleton instance. | |
Private Member Functions | |
typedef | BLAZE_TYPELIST_8 (SystemClock, NullType, NullType, NullType, NullType, NullType, NullType, NullType) Dependencies |
Type list of all lifetime dependencies. | |
Constructors | |
Logger () | |
Constructor for the Logger class. | |
Logging functions | |
template<typename Type > | |
void | log (const Type &message) |
Writes the log message to the log file. More... | |
Utility functions | |
void | openLogFile () |
Opens and initializes the log file. More... | |
Static Private Member Functions | |
Instance function | |
static boost::shared_ptr< Logger > | instance () |
Private Attributes | |
Member variables | |
boost::mutex | mutex_ |
Synchronization mutex for thread-parallel logging. | |
std::ofstream | log_ |
The log file. | |
Static Private Attributes | |
Member variables | |
static boost::mutex | instanceMutex_ |
Synchronization mutex for access to the singleton. | |
Implementation of a logger class.
The Logger class represents the core of the logging functionality. It is responsible for commiting logging messages immediately to the according log file(s). The logger works for both serial as well as MPI parallel environments. In case of a non-MPI-parallel simulation the Logger creates the log file 'blaze.log', which contains all logging information from all logging levels. In case of a MPI parallel simulation, each process creates his own individual log file called 'blazeX.log', where 'X' is replaced by the according rank the process has in the MPI_COMM_WORLD communicator.
Note that the log file(s) are only created in case any logging information is created. This might for instance result in only a small number of log file(s) in MPI parallel simulations when only some of the processes encounter errors/warnings/etc.
Note that the logging functionality may not be used before MPI_Init() has been finished. In consequence, this means that no global data that is initialized before the main() function may contain any use of the logging functionality!
blaze::logging::Logger::~Logger | ( | ) |
|
private |
Writes the log message to the log file.
message | The log message to be logged. |
This function immediately commits the log message to the log file. The first call to this function will create the log file.
|
private |
Opens and initializes the log file.
This function is responsible for opening the log file and writing the header line. In case of a non-MPI-parallel simulation the function creates the log file 'blaze.log', which contains all logging information from all logging levels. In case of a MPI parallel simulation, each process creates his own individual log file called 'blazeX.log', where 'X' is replaced by the according rank the process has in the MPI_COMM_WORLD communicator.