Stream buffer for the message logger. More...
Classes | |
struct | Settings |
Public Member Functions | |
LoggerBuffer (const LoggerBuffer &other)=delete | |
LoggerBuffer (int nProcesses, int rank, std::size_t bufferSize=256) | |
LoggerBuffer (LoggerBuffer &&other)=delete | |
~LoggerBuffer () | |
int | flush (bool terminate) |
std::ostream & | getConsoleStream () |
std::ofstream & | getFileStream () |
int | getProcessCount () const |
int | getRank () const |
const Settings * | getSettings () const |
void | setConsoleEnabled (bool enabled) |
void | setConsoleStream (std::ostream *console) |
void | setFileEnabled (bool enabled) |
void | setFileStream (std::ofstream *file) |
void | setSettings (const std::shared_ptr< Settings > &settings) |
Stream buffer for the message logger.
This class implements a stream buffer used by the message logger.
Definition at line 83 of file logger.hpp.
bitpit::LoggerBuffer::LoggerBuffer | ( | int | nProcesses, |
int | rank, | ||
std::size_t | bufferSize = 256 ) |
Creates a new buffer.
nProcesses | is the total number of processes in the communicator |
rank | is the parallel rank in the communicator |
bufferSize | is the size of the internal buffer |
Definition at line 63 of file logger.cpp.
bitpit::LoggerBuffer::~LoggerBuffer | ( | ) |
Destructor
Definition at line 100 of file logger.cpp.
int bitpit::LoggerBuffer::flush | ( | bool | terminate | ) |
Flushes stream buffer.
terminate | if true ensures that a new line is added as last character |
Definition at line 173 of file logger.cpp.
std::ostream & bitpit::LoggerBuffer::getConsoleStream | ( | ) |
Gets the stream to be used for the output on the console.
Definition at line 333 of file logger.cpp.
std::ofstream & bitpit::LoggerBuffer::getFileStream | ( | ) |
Gets the stream to be used for the output on the file.
Definition at line 375 of file logger.cpp.
int bitpit::LoggerBuffer::getProcessCount | ( | ) | const |
Count the number of processes in the communicator.
Definition at line 110 of file logger.cpp.
int bitpit::LoggerBuffer::getRank | ( | ) | const |
Gets the rank in the communicator.
Definition at line 120 of file logger.cpp.
const LoggerBuffer::Settings * bitpit::LoggerBuffer::getSettings | ( | ) | const |
Get a constant pointer to the buffer settings.
Definition at line 385 of file logger.cpp.
void bitpit::LoggerBuffer::setConsoleEnabled | ( | bool | enabled | ) |
Enables the output on the console.
enabled | if set to true enables the console output. |
Definition at line 305 of file logger.cpp.
void bitpit::LoggerBuffer::setConsoleStream | ( | std::ostream * | console | ) |
Sets the stream to be used for the output on the console.
console | is the stream to be used for the output on the console |
Definition at line 321 of file logger.cpp.
void bitpit::LoggerBuffer::setFileEnabled | ( | bool | enabled | ) |
Enables the output on the log file.
The output on the log file can be enabled only id the log file path has been set. If there is no log file path specified, the output on the file will not be enabled.
enabled | if set to true enables the output on the log file |
Definition at line 347 of file logger.cpp.
void bitpit::LoggerBuffer::setFileStream | ( | std::ofstream * | file | ) |
Sets the stream to be used for the output on the file.
file | is the stream to be used for the output on the file |
Definition at line 363 of file logger.cpp.
void bitpit::LoggerBuffer::setSettings | ( | const std::shared_ptr< Settings > & | settings | ) |
Sets buffer settings.
settings | are the buffer settings |
Definition at line 395 of file logger.cpp.