41 ASSERT(seconds > -numeric_limits<double>::epsilon())(seconds).error(
"Formating of negative time.");
43 unsigned int h,m,s,ms;
44 unsigned int full_time = (int)(seconds * 1000);
46 ms = full_time % 1000;
60 if (ms<100) ss <<
"0";
75 : mpi_rank_(-1), init_flag_(
InitFlag::uninitialize) {}
87 ASSERT(
init_flag_ == InitFlag::uninitialize).error(
"Setup MPI must be performed before setting logger file.");
94 ASSERT(
init_flag_ == InitFlag::uninitialize).error(
"Recurrent initialization of logger file stream.");
96 if ( (log_file_base.size()) == 0 || (log_file_base ==
"//") ) {
102 if (mpi_rank == -1) {
103 std::random_device rd;
104 std::mt19937 gen(rd());
105 std::uniform_int_distribution<int> dis(0, 999999);
107 WarningOut() <<
"Unset MPI rank, random value '" << mpi_rank <<
"' of rank will be used.\n";
109 std::stringstream file_name;
110 file_name << log_file_base <<
"." << mpi_rank <<
".log";
111 return file_name.str();
116 ASSERT(
init_flag_ == InitFlag::uninitialize).error(
"Recurrent initialization of logger file stream.");
120 THROW( ExcMessage() << EI_Message(
"Can not open logger file: '" + abs_path +
"'!") );
void set_stream(std::string abs_path)
Set init_ flag.
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.
static LoggerOptions * instance_
Singleton instance.
int mpi_rank_
Actual process number.
static LoggerOptions & get_instance()
Getter of singleton instance object.
~LoggerOptions()
Destructor.
void reset()
Reset MPI rank and log file name.
void set_mpi_rank(int mpi_rank)
Set rank of actual process.
std::string log_file_name(std::string log_file_base)
Create unique log file name.
static std::string format_hh_mm_ss()
InitFlag init_flag_
Flag sign if logger is initialized.
std::ofstream file_stream_
Stream for storing logger messages to file.
InitFlag
Initialization flag of Logger.
Global macros to enhance readability and debugging, general constants.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
#define WarningOut()
Macro defining 'warning' record of log.