|
void | set_mask () |
| Set streams_mask_ according to the type of message. More...
|
|
void | print_to_screen (std::ostream &stream, std::stringstream &scr_stream, StreamMask mask) |
| Print formated message to given screen stream if mask corresponds with streams_mask_ . More...
|
|
void | print_to_file (std::ofstream &stream, std::stringstream &file_stream, StreamMask mask) |
| Print formated message to given file stream if mask corresponds with streams_mask_ . More...
|
|
bool | print_screen_header (std::ostream &stream, std::stringstream &scr_stream) |
| Print header to screen stream, helper method called from print_to_screen . More...
|
|
void | print_file_header (std::ofstream &stream, std::stringstream &file_stream) |
| Print header to file stream, helper method called from print_to_file . More...
|
|
std::string | compact_file_name (std::string file_name) |
| Return compact (relative) path to the given source file. More...
|
|
Class for storing logger messages.
Allow define different levels of log messages and distinguish output streams for individual leves. These output streams are -
- standard console output (std::cout)
- standard error output (std::cerr)
- file output (see
LoggerOptions
class)
Logger distinguishes four type of levels -
- warning: printed to standard error and file output
- message: printed to standard console and file output
- log: printed to file output
- debug: printed to file output (level is used only in debug mode)
File output is optional. See LoggerOptions
for setting this output stream.
Example of Logger usage:
For individual levels are defined macros -
Logger message is created by using an operator << and allow to add each type that has override this operator. Message is terminated with manipulator std::endl. Implicitly logger message is printed only in processor with rank zero. If necessary printed message for all process, it provides a method every_proc().
Examples of logger messages formating:
MessageOut() <<
"End of simulation at time: " << secondary_eq->solved_time() <<
"\n";
WarningOut() <<
"Unprocessed key '" << key_name <<
"' in Record '" << rec->type_name() <<
"'." <<
"\n";
LogOut() <<
"Write output to output stream: " << this->_base_filename <<
" for time: " << time <<
"\n";
DebugOut() <<
"Calling 'initialize' of empty equation '" <<
typeid(*this).name() <<
"'." <<
"\n";
Logger message can be created by more than one line ("\n" can be used multiple times):
MessageOut() <<
"Start time: " << this->start_time() <<
"\n" <<
"End time: " << this->end_time() <<
"\n";
Or Logger allow using fmtlib functionality for simpler formatting of message:
MessageOut().fmt(
"Start time: {}\nEnd time: {}\n", this->start_time(), this->end_time());
In some cases message can be printed for all processes:
MessageOut().every_proc() <<
"Size distributed at process: " << distr->lsize() <<
"\n";
Implementation of Logger does not support manipulator std::endl. Please, use "\n" instead.
Definition at line 137 of file logger.hh.