Flow123d  JB_release_tests-c4abd42
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
LoggerOptions Class Reference

#include <logger_options.hh>

Collaboration diagram for LoggerOptions:
Collaboration graph
[legend]

Public Types

enum  InitFlag { uninitialize , no_log , initialize }
 Initialization flag of Logger. More...
 

Public Member Functions

int get_mpi_rank () const
 Returns number of actual process, if MPI is not supported returns -1. More...
 
void set_mpi_rank (int mpi_rank)
 Set rank of actual process. More...
 
void reset ()
 Reset MPI rank and log file name. More...
 
LoggerOptions::InitFlag init_flag ()
 Check if singleton instance object is initialize. More...
 
void set_stream (std::string abs_path)
 Set init_ flag. More...
 
std::string log_file_name (std::string log_file_base)
 Create unique log file name. More...
 
 ~LoggerOptions ()
 Destructor. More...
 

Static Public Member Functions

static LoggerOptionsget_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...
 
InitFlag init_flag_
 Flag sign if logger is initialized. 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 LoggerOptionsinstance_ = new LoggerOptions()
 Singleton instance. More...
 

Friends

class Logger
 

Detailed Description

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:

std::string log_file_prefix;
int mpi_rank;
// ... set value of log_file_prefix
MPI_Comm_rank(comm, &mpi_rank);
LoggerOptions::get_instance().setup_mpi(mpi_rank);
LoggerOptions::get_instance().set_log_file(log_file_prefix);
static LoggerOptions & get_instance()
Getter of singleton instance object.
#define MPI_Comm_rank
Definition: mpi.h:236

Definition at line 57 of file logger_options.hh.

Member Enumeration Documentation

◆ InitFlag

Initialization flag of Logger.

Enumerator
uninitialize 
no_log 
initialize 

Definition at line 61 of file logger_options.hh.

Constructor & Destructor Documentation

◆ ~LoggerOptions()

LoggerOptions::~LoggerOptions ( )

Destructor.

Definition at line 78 of file logger_options.cc.

◆ LoggerOptions()

LoggerOptions::LoggerOptions ( )
private

Forbidden constructor.

Definition at line 74 of file logger_options.cc.

Member Function Documentation

◆ format_hh_mm_ss()

std::string LoggerOptions::format_hh_mm_ss ( )
static

Return actual time from the beginning of application runtime in format HH:MM:SS.SSS

Definition at line 38 of file logger_options.cc.

Here is the caller graph for this function:

◆ get_instance()

LoggerOptions & LoggerOptions::get_instance ( )
static

Getter of singleton instance object.

Definition at line 32 of file logger_options.cc.

Here is the caller graph for this function:

◆ get_mpi_rank()

int LoggerOptions::get_mpi_rank ( ) const
inline

Returns number of actual process, if MPI is not supported returns -1.

Definition at line 76 of file logger_options.hh.

Here is the caller graph for this function:

◆ init_flag()

LoggerOptions::InitFlag LoggerOptions::init_flag ( )
inline

Check if singleton instance object is initialize.

Definition at line 87 of file logger_options.hh.

Here is the caller graph for this function:

◆ log_file_name()

std::string LoggerOptions::log_file_name ( std::string  log_file_base)

Create unique log file name.

Definition at line 93 of file logger_options.cc.

Here is the caller graph for this function:

◆ reset()

void LoggerOptions::reset ( )

Reset MPI rank and log file name.

Definition at line 126 of file logger_options.cc.

◆ set_mpi_rank()

void LoggerOptions::set_mpi_rank ( int  mpi_rank)

Set rank of actual process.

Definition at line 86 of file logger_options.cc.

Here is the caller graph for this function:

◆ set_stream()

void LoggerOptions::set_stream ( std::string  abs_path)

Set init_ flag.

Definition at line 115 of file logger_options.cc.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Logger

friend class Logger
friend

Definition at line 121 of file logger_options.hh.

Member Data Documentation

◆ file_stream_

std::ofstream LoggerOptions::file_stream_
private

Stream for storing logger messages to file.

Definition at line 109 of file logger_options.hh.

◆ init_flag_

InitFlag LoggerOptions::init_flag_
private

Flag sign if logger is initialized.

Definition at line 119 of file logger_options.hh.

◆ instance_

LoggerOptions * LoggerOptions::instance_ = new LoggerOptions()
staticprivate

Singleton instance.

Definition at line 106 of file logger_options.hh.

◆ mpi_rank_

int LoggerOptions::mpi_rank_
private

Actual process number.

Default value is set to -1 and indicates that MPI is not set

Definition at line 116 of file logger_options.hh.

◆ start_time

TimePoint LoggerOptions::start_time = TimePoint()
staticprivate

Start time of program, allows you to specify the actual time of program (see format_hh_mm_ss method)

Definition at line 103 of file logger_options.hh.


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