|
ACF $AcfVersion:0$
|
Redirects C++ standard output streams (cout/cerr) to the logging system. More...
#include <CStandardStreamBridge.h>
Public Types | |
| typedef std::basic_streambuf< char > | BaseClass |
| Base class typedef. | |
Public Member Functions | |
| CStandardStreamBridge (std::ostream &stream, ilog::IMessageConsumer &messageConsumer, istd::IInformationProvider::InformationCategory informationSeverity) | |
| Construct a stream bridge and activate redirection. | |
| virtual | ~CStandardStreamBridge () |
| Destructor - restores original stream buffer. | |
Protected Member Functions | |
| virtual std::streamsize | xsputn (const char *data, std::streamsize bufferSize) override |
| Handle bulk character writes. | |
| virtual int_type | overflow (int_type v) override |
| Handle single character writes. | |
Redirects C++ standard output streams (cout/cerr) to the logging system.
CStandardStreamBridge intercepts output sent to std::cout or std::cerr and converts it into log messages. This is useful for capturing output from legacy code, third-party libraries, or console-based diagnostics.
The class inherits from std::basic_streambuf and replaces the stream's buffer, capturing all output that would normally go to the console and instead sending it as log messages.
Definition at line 80 of file CStandardStreamBridge.h.
| typedef std::basic_streambuf<char> ilog::CStandardStreamBridge::BaseClass |
Base class typedef.
Definition at line 84 of file CStandardStreamBridge.h.
| ilog::CStandardStreamBridge::CStandardStreamBridge | ( | std::ostream & | stream, |
| ilog::IMessageConsumer & | messageConsumer, | ||
| istd::IInformationProvider::InformationCategory | informationSeverity | ||
| ) |
Construct a stream bridge and activate redirection.
Replaces the stream's buffer with this bridge, capturing all output.
| stream | Reference to stream to bridge (std::cout, std::cerr, etc.) |
| messageConsumer | Consumer to receive converted messages |
| informationSeverity | Severity level for generated messages |
|
virtual |
Destructor - restores original stream buffer.
When the bridge is destroyed, the original stream buffer is restored, returning the stream to normal console output.
|
overrideprotectedvirtual |
Handle single character writes.
Called when a single character is written. Accumulates in buffer until newline, then sends as message.
| v | Character to write |
|
overrideprotectedvirtual |
Handle bulk character writes.
Called when multiple characters are written at once. Accumulates characters in internal buffer until newline, then sends as message.
| data | Pointer to character data |
| bufferSize | Number of characters to write |