![]() |
MAiNGO
|
This class contains all logging and output information. More...
#include <logger.h>
Public Member Functions | |
Logger () | |
Default constructor. More... | |
Logger (const Logger &)=default | |
Default copy constructor. More... | |
Logger & | operator= (const Logger &)=default |
Default copy assignment. More... | |
~Logger () | |
Default destructor. More... | |
void | print_message (const std::string &message, const VERB verbosityGiven, const VERB verbosityNeeded, const LOGGING_DESTINATION givenOutstreamVerbosity) |
The main function used for printing a given message and storing it in log and/or csv. More... | |
void | print_message_to_stream_only (const std::string &message, const LOGGING_DESTINATION givenOutstreamVerbosity) |
The main function used for printing a given message and storing it in log and/or csv. More... | |
void | set_output_stream (std::ostream *const outputStream) |
Sets output stream. More... | |
void | create_log_file (const LOGGING_DESTINATION givenOutstreamVerbosity) |
Function used for creating the log file. More... | |
void | create_iterations_csv_file (const bool writeCsv) |
Function used for creating the csv file with information on the B&B iterations. More... | |
void | write_all_lines_to_log (const std::string &errorMessage="") |
Function used for writing all lines stored in queue babLine to log. More... | |
void | write_all_iterations_to_csv () |
Function used for writing all iterations currently stored queue babLineCsv to csv. More... | |
void | save_settings_file_name (const std::string &fileName, const bool fileFound) |
Function used for saving the names of setting files set by the user. More... | |
void | save_setting (const SETTING_NAMES settingName, const std::string &str) |
Function used for saving the user-set settings. More... | |
void | print_settings (const VERB verbosityGiven, const VERB verbosityNeeded, const LOGGING_DESTINATION givenOutstreamVerbosity) |
Function for printing and writing user-set settings. More... | |
void | clear () |
Clears all logging information. More... | |
Public Attributes | |
Auxiliary public variables for storing output and logging information | |
std::queue< std::string > | babLine {} |
std::queue< std::string > | babLineCsv {} |
std::string | logFileName = "maingo.log" |
std::string | csvIterationsName = "iterations.csv" |
bool | reachedMinNodeSize |
Private Attributes | |
Private variable storing the output | |
std::ostream * | _outStream = &std::cout |
unsigned int | _nSettingFiles = 0 |
std::map< int, std::string > | _userSetSettings |
This class contains all logging and output information.
This class is used by the MAiNGO, BranchAndBound, LowerBoundingSolver and UpperBoundingSolver classes for a central and proper storing of output and logging information.
|
inline |
Default constructor.
|
default |
Default copy constructor.
|
inline |
Default destructor.
void Logger::clear | ( | ) |
Clears all logging information.
void Logger::create_iterations_csv_file | ( | const bool | writeCsv | ) |
Function used for creating the csv file with information on the B&B iterations.
[in] | writeCsv | says whether to write the csv file |
void Logger::create_log_file | ( | const LOGGING_DESTINATION | givenOutstreamVerbosity | ) |
Function used for creating the log file.
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::print_message | ( | const std::string & | message, |
const VERB | verbosityGiven, | ||
const VERB | verbosityNeeded, | ||
const LOGGING_DESTINATION | givenOutstreamVerbosity | ||
) |
The main function used for printing a given message and storing it in log and/or csv.
[in] | message | is the message to be printed or written |
[in] | verbosityGiven | is the verbosity given by, e.g., settings |
[in] | verbosityNeeded | is the least verbosity needed for the message to be printed/written |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::print_message_to_stream_only | ( | const std::string & | message, |
const LOGGING_DESTINATION | givenOutstreamVerbosity | ||
) |
The main function used for printing a given message and storing it in log and/or csv.
[in] | message | is the message to be printed or written |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::print_settings | ( | const VERB | verbosityGiven, |
const VERB | verbosityNeeded, | ||
const LOGGING_DESTINATION | givenOutstreamVerbosity | ||
) |
Function for printing and writing user-set settings.
[in] | verbosityGiven | is the verbosity given by, e.g., settings |
[in] | verbosityNeeded | is the least verbosity needed for the message to be printed/written |
[in] | givenOutstreamVerbosity | tells whether to print to _outStream and/or write files |
void Logger::save_setting | ( | const SETTING_NAMES | settingName, |
const std::string & | str | ||
) |
Function used for saving the user-set settings.
[in] | settingName | is the changed setting |
[in] | str | is the corresponding string |
void Logger::save_settings_file_name | ( | const std::string & | fileName, |
const bool | fileFound | ||
) |
Function used for saving the names of setting files set by the user.
[in] | fileName | it the name of the file set by the user |
[in] | fileFound | tells whether the wanted file has been found |
void Logger::set_output_stream | ( | std::ostream *const | outputStream | ) |
Sets output stream.
[in] | outputStream | is the new output stream to be used by MAiNGO. |
void Logger::write_all_iterations_to_csv | ( | ) |
Function used for writing all iterations currently stored queue babLineCsv to csv.
void Logger::write_all_lines_to_log | ( | const std::string & | errorMessage = "" | ) |
Function used for writing all lines stored in queue babLine to log.
[in] | errorMessage | is a possible additional error message |
|
private |
number of setting files from which the user has read, default is set to 0
|
private |
default MAiNGO output stream is set to std::cout
|
private |
map holding settings set by the user
std::queue<std::string> maingo::Logger::babLine {} |
queue for storing lines of B&B output
std::queue<std::string> maingo::Logger::babLineCsv {} |
queue for storing lines of B&B output for CSV file
std::string maingo::Logger::csvIterationsName = "iterations.csv" |
name of the csv file into which information on the individual B&B iterations may be written
std::string maingo::Logger::logFileName = "maingo.log" |
name of the txt file into which the log may be written
bool maingo::Logger::reachedMinNodeSize |
bool for saving information if minimum node size has been reached within B&B