AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
Public Member Functions | List of all members
drama::logging::LogStreamBuf Class Reference

Detailed Description

Implement a streambuf sub-class that can write messages via the DRAMA Logger interface.


This class implements std::streambuf, which allows it to be used as an output stream buffer for character based output streams (std::ostream). Messages are output via the DRAMA Logger.

You can use this to create an std::ostream which can be used to output to the log file.

"d2::SetupWaitEvent");
std::ostream slogger(&logBuf);
slogger << "Message for log file" << std::endl;
Implement a streambuf sub-class that can write messages via the DRAMA Logger interface.
Definition logger.hh:379
#define D2LOG_DRAMA2
DRAMA 2 events - thread events etc.
Definition logger.hh:107
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
Note
A new DRAMA Log event happens sent each time the buffer is flushed, which will happen if a std::endl is output or if the number of queue characters exceeds 200. In the later case, the message will be broken between multiple log events.
Warning
Any text not flushed when the destructor is invoked will be flushed by the destructor. In some cases, this may result in messages appearing outside the expected order. It is recommended all message be terminated by a std::endl to avoid this happening.

Implementation based on code in "The C++ Standard Library", Second Edition, N.M. Josuttis, Pages 837/838.

Author
Tony Farrell, AAO $Revision$ $Date$

#include "logger.hh"

Inherits std::streambuf.

Public Member Functions

 LogStreamBuf (const LogStreamBuf &source)=delete
 Copy constructor - deleted.
 
 LogStreamBuf (Logger *theLogger, unsigned level, const std::string &prefix)
 Construct a LogStreamBuf object.
 
 LogStreamBuf (LogStreamBuf &&source) noexcept
 Move copy constructor.
 
virtual ~LogStreamBuf ()
 Destroy the LogStreamBuf, any remaining output is sent.
 
LogStreamBufoperator= (const LogStreamBuf &rhs)=delete
 Assignment operator - deleted.
 
LogStreamBufoperator= (LogStreamBuf &&rhs) noexcept
 Move assignment operator.
 

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