Output Stream that outputs only on master rank of a worldcomm. More...
Collaboration diagram for Feel::MasterStream:Public Types | |
| using | LogLevel = Logger::Level |
Public Member Functions | |
| void | attachWorldComm (std::shared_ptr< WorldComm > &_wc) |
| void | close () |
| provides close() from std::ofstream Only closes on master rank when MPI is active | |
| void | flush () const |
| Explicit flush method. | |
| MasterStream (std::ostream &_out, std::shared_ptr< WorldComm > _wc=nullptr, LogLevel _log_level=Logger::Level::info) | |
| Construct a MasterStream from a std::ostream and optionally a WorldComm. More... | |
| template<typename... Args> | |
| void | open (Args... args) |
| variadic template function to provide open() from std::ofstream Only opens on master rank when MPI is active | |
| template<typename T > | |
| const MasterStream & | operator<< (const T &v) const |
| Output operator for generic types Buffers output and sends to both stream and logging backend on flush. | |
| MasterStream const & | operator<< (std::ostream &(*F)(std::ostream &)) const |
| Output operator for stream manipulators (std::endl, std::flush, etc.) Flushes buffer to both output stream and logging backend. | |
| void | setLogLevel (LogLevel level) |
| Set the log level for this stream. | |
| std::string | str () const |
provide an interface to str() for ostringstream More... | |
| std::shared_ptr< WorldComm > | worldCommPtr () const |
Protected Attributes | |
| std::ostringstream | buffer |
| Internal buffer for line-based output. | |
| LogLevel | log_level |
| Log severity level. | |
| std::ostream & | out |
| Underlying output stream. | |
| std::shared_ptr< WorldComm > | wc |
| WorldComm for MPI rank checking. | |
Output Stream that outputs only on master rank of a worldcomm.
The first application is to use the instantiation of MasterStream cout, cerr or clog to default output on master rank process of a Feel++ application
Behavior based on MPI state:
Logging integration:
This ensures MasterStream is safe to use throughout the entire program lifecycle, including during global object construction/destruction.
| Feel::MasterStream::MasterStream | ( | std::ostream & | _out, |
| std::shared_ptr< WorldComm > | _wc = nullptr, |
||
| LogLevel | _log_level = Logger::Level::info |
||
| ) |
Construct a MasterStream from a std::ostream and optionally a WorldComm.
If no WorldComm is provided, it will be retrieved from Environment when needed.
| _out | the underlying output stream (std::cout, std::cerr, etc.) |
| _wc | optional WorldComm pointer (defaults to nullptr, retrieved lazily) |
| _log_level | the log level for logging backend (info, warn, err) |
| std::string Feel::MasterStream::str | ( | ) | const |
provide an interface to str() for ostringstream