MAiNGO
maingo::Logger Class Reference

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...
 
Loggeroperator= (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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Logger() [1/2]

maingo::Logger::Logger ( )
inline

Default constructor.

◆ Logger() [2/2]

maingo::Logger::Logger ( const Logger )
default

Default copy constructor.

◆ ~Logger()

maingo::Logger::~Logger ( )
inline

Default destructor.

Member Function Documentation

◆ clear()

void Logger::clear ( )

Clears all logging information.

◆ create_iterations_csv_file()

void Logger::create_iterations_csv_file ( const bool  writeCsv)

Function used for creating the csv file with information on the B&B iterations.

Parameters
[in]writeCsvsays whether to write the csv file

◆ create_log_file()

void Logger::create_log_file ( const LOGGING_DESTINATION  givenOutstreamVerbosity)

Function used for creating the log file.

Parameters
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ operator=()

Logger& maingo::Logger::operator= ( const Logger )
default

Default copy assignment.

◆ print_message()

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.

Parameters
[in]messageis the message to be printed or written
[in]verbosityGivenis the verbosity given by, e.g., settings
[in]verbosityNeededis the least verbosity needed for the message to be printed/written
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ print_message_to_stream_only()

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.

Parameters
[in]messageis the message to be printed or written
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ print_settings()

void Logger::print_settings ( const VERB  verbosityGiven,
const VERB  verbosityNeeded,
const LOGGING_DESTINATION  givenOutstreamVerbosity 
)

Function for printing and writing user-set settings.

Parameters
[in]verbosityGivenis the verbosity given by, e.g., settings
[in]verbosityNeededis the least verbosity needed for the message to be printed/written
[in]givenOutstreamVerbositytells whether to print to _outStream and/or write files

◆ save_setting()

void Logger::save_setting ( const SETTING_NAMES  settingName,
const std::string &  str 
)

Function used for saving the user-set settings.

Parameters
[in]settingNameis the changed setting
[in]stris the corresponding string

◆ save_settings_file_name()

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.

Parameters
[in]fileNameit the name of the file set by the user
[in]fileFoundtells whether the wanted file has been found

◆ set_output_stream()

void Logger::set_output_stream ( std::ostream *const  outputStream)

Sets output stream.

Parameters
[in]outputStreamis the new output stream to be used by MAiNGO.

◆ write_all_iterations_to_csv()

void Logger::write_all_iterations_to_csv ( )

Function used for writing all iterations currently stored queue babLineCsv to csv.

◆ write_all_lines_to_log()

void Logger::write_all_lines_to_log ( const std::string &  errorMessage = "")

Function used for writing all lines stored in queue babLine to log.

Parameters
[in]errorMessageis a possible additional error message

Member Data Documentation

◆ _nSettingFiles

unsigned int maingo::Logger::_nSettingFiles = 0
private

number of setting files from which the user has read, default is set to 0

◆ _outStream

std::ostream* maingo::Logger::_outStream = &std::cout
private

default MAiNGO output stream is set to std::cout

◆ _userSetSettings

std::map<int, std::string> maingo::Logger::_userSetSettings
private

map holding settings set by the user

◆ babLine

std::queue<std::string> maingo::Logger::babLine {}

queue for storing lines of B&B output

◆ babLineCsv

std::queue<std::string> maingo::Logger::babLineCsv {}

queue for storing lines of B&B output for CSV file

◆ csvIterationsName

std::string maingo::Logger::csvIterationsName = "iterations.csv"

name of the csv file into which information on the individual B&B iterations may be written

◆ logFileName

std::string maingo::Logger::logFileName = "maingo.log"

name of the txt file into which the log may be written

◆ reachedMinNodeSize

bool maingo::Logger::reachedMinNodeSize

bool for saving information if minimum node size has been reached within B&B


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