ACF $AcfVersion:0$
CStandardStreamBridge.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// STL includes
6#include <iostream>
7#include <streambuf>
8#include <string>
9
10// Qt includes
11#include <QtCore/QString>
12#include <QtCore/QMutex>
13
14// ACF includes
16
17
18namespace ilog
19{
20
21
80class CStandardStreamBridge: protected std::basic_streambuf<char>
81{
82public:
84 typedef std::basic_streambuf<char> BaseClass;
85
106 std::ostream &stream,
107 ilog::IMessageConsumer& messageConsumer,
109
117
118protected:
119 // reimplemented (std::basic_streambuf)
120
131 virtual std::streamsize xsputn(const char* data, std::streamsize bufferSize) override;
132
142 virtual int_type overflow(int_type v) override;
143
144private:
146 std::ostream& m_stream;
147
149 std::streambuf* m_originalBufferPtr;
150
152 ilog::IMessageConsumer& m_messageConsumer;
153
156
158 QString m_textBuffer;
159
161 mutable QMutex m_bufferMutex;
162};
163
164
165} // namespace ilog
166
167
168
169
Redirects C++ standard output streams (cout/cerr) to the logging system.
virtual int_type overflow(int_type v) override
Handle single character writes.
CStandardStreamBridge(std::ostream &stream, ilog::IMessageConsumer &messageConsumer, istd::IInformationProvider::InformationCategory informationSeverity)
Construct a stream bridge and activate redirection.
virtual std::streamsize xsputn(const char *data, std::streamsize bufferSize) override
Handle bulk character writes.
virtual ~CStandardStreamBridge()
Destructor - restores original stream buffer.
std::basic_streambuf< char > BaseClass
Base class typedef.
Common interface for a message container consuming information objects (messages).
InformationCategory
Category of information.
This namespace contains implementations for the logging functionality.