Flow123d
JS_before_hm-978-gf0793cd
|
#include <logger_options.hh>
Public Member Functions | |
int | get_mpi_rank () |
Returns number of actual process, if MPI is not supported returns -1. More... | |
int | setup_mpi (MPI_Comm comm) |
Set rank of actual process by MPI communicator. More... | |
void | set_log_file (std::string log_file_base) |
Initialize instance object in format 'log_file_base.process.log'. More... | |
void | reset () |
Reset MPI rank and log file name. More... | |
bool | is_init () |
Check if singleton instance object is initialize. More... | |
~LoggerOptions () | |
Destructor. More... | |
Static Public Member Functions | |
static LoggerOptions & | get_instance () |
Getter of singleton instance object. More... | |
static std::string | format_hh_mm_ss () |
Private Member Functions | |
LoggerOptions () | |
Forbidden constructor. More... | |
Private Attributes | |
std::ofstream | file_stream_ |
Stream for storing logger messages to file. More... | |
int | mpi_rank_ |
Actual process number. More... | |
bool | no_log_ |
Turn off logger file output. More... | |
bool | init_ |
Flag sign if logger is initialized by set_log_file method. More... | |
Static Private Attributes | |
static TimePoint | start_time = TimePoint() |
Start time of program, allows you to specify the actual time of program (see format_hh_mm_ss method) More... | |
static LoggerOptions * | instance_ = new LoggerOptions() |
Singleton instance. More... | |
Friends | |
class | Logger |
Helper class defined logger output file and flags for setting of logger.
Use singleton design pattern.
Setting of logger is ensured by two methods: setup_mpi and set_log_file. Both methods are optional.
Example of complete initialization of logger:
Definition at line 55 of file logger_options.hh.
LoggerOptions::~LoggerOptions | ( | ) |
Destructor.
Definition at line 77 of file logger_options.cc.
|
private |
Forbidden constructor.
Definition at line 73 of file logger_options.cc.
|
static |
Return actual time from the beginning of application runtime in format HH:MM:SS.SSS
Definition at line 37 of file logger_options.cc.
|
static |
Getter of singleton instance object.
Definition at line 31 of file logger_options.cc.
int LoggerOptions::get_mpi_rank | ( | ) |
Returns number of actual process, if MPI is not supported returns -1.
Definition at line 85 of file logger_options.cc.
|
inline |
Check if singleton instance object is initialize.
Definition at line 79 of file logger_options.hh.
void LoggerOptions::reset | ( | ) |
Reset MPI rank and log file name.
Definition at line 119 of file logger_options.cc.
void LoggerOptions::set_log_file | ( | std::string | log_file_base | ) |
Initialize instance object in format 'log_file_base.process.log'.
Definition at line 97 of file logger_options.cc.
int LoggerOptions::setup_mpi | ( | MPI_Comm | comm | ) |
Set rank of actual process by MPI communicator.
Definition at line 90 of file logger_options.cc.
|
friend |
Definition at line 110 of file logger_options.hh.
|
private |
Stream for storing logger messages to file.
Definition at line 95 of file logger_options.hh.
|
private |
Flag sign if logger is initialized by set_log_file method.
Definition at line 108 of file logger_options.hh.
|
staticprivate |
Singleton instance.
Definition at line 92 of file logger_options.hh.
|
private |
Actual process number.
Default value is set to -1 and indicates that MPI is not set
Definition at line 102 of file logger_options.hh.
|
private |
Turn off logger file output.
Definition at line 105 of file logger_options.hh.
Start time of program, allows you to specify the actual time of program (see format_hh_mm_ss
method)
Definition at line 89 of file logger_options.hh.