Flow123d
JS_before_hm-2137-g84767e588
|
Go to the documentation of this file.
40 ASSERT(seconds > -numeric_limits<double>::epsilon())(seconds).error(
"Formating of negative time.");
42 unsigned int h,m,s,ms;
43 unsigned int full_time = (int)(seconds * 1000);
45 ms = full_time % 1000;
59 if (ms<100) ss <<
"0";
74 : mpi_rank_(-1), no_log_(false), init_(false) {}
91 ASSERT(!
init_).error(
"Setup MPI must be performed before setting logger file.");
98 ASSERT(!
init_).error(
"Recurrent initialization of logger file stream.");
100 if (log_file_base.size() == 0) {
104 if (mpi_rank == -1) {
105 std::random_device rd;
106 std::mt19937 gen(rd());
107 std::uniform_int_distribution<int> dis(0, 999999);
109 WarningOut() <<
"Unset MPI rank, random value '" << mpi_rank <<
"' of rank will be used.\n";
111 std::stringstream file_name;
112 file_name << log_file_base <<
"." << mpi_rank <<
".log";
static TimePoint start_time
Start time of program, allows you to specify the actual time of program (see format_hh_mm_ss method)
LoggerOptions()
Forbidden constructor.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
bool no_log_
Turn off logger file output.
Dedicated class for storing path to input and output files.
~LoggerOptions()
Destructor.
void open_stream(Stream &stream) const
static LoggerOptions & get_instance()
Getter of singleton instance object.
int get_mpi_rank()
Returns number of actual process, if MPI is not supported returns -1.
std::ofstream file_stream_
Stream for storing logger messages to file.
bool init_
Flag sign if logger is initialized by set_log_file method.
void set_log_file(std::string log_file_base)
Initialize instance object in format 'log_file_base.process.log'.
static LoggerOptions * instance_
Singleton instance.
void reset()
Reset MPI rank and log file name.
Global macros to enhance readability and debugging, general constants.
#define WarningOut()
Macro defining 'warning' record of log.
int setup_mpi(MPI_Comm comm)
Set rank of actual process by MPI communicator.
int mpi_rank_
Actual process number.
static std::string format_hh_mm_ss()