1 | // |
2 | // StreamChannel.h |
3 | // |
4 | // Library: Foundation |
5 | // Package: Logging |
6 | // Module: StreamChannel |
7 | // |
8 | // Definition of the StreamChannel class. |
9 | // |
10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef Foundation_StreamChannel_INCLUDED |
18 | #define Foundation_StreamChannel_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Foundation.h" |
22 | #include "Poco/Channel.h" |
23 | #include "Poco/Mutex.h" |
24 | #include <ostream> |
25 | |
26 | |
27 | namespace Poco { |
28 | |
29 | |
30 | class Foundation_API StreamChannel: public Channel |
31 | /// A channel that writes to an ostream. |
32 | /// |
33 | /// Only the message's text is written, followed |
34 | /// by a newline. |
35 | /// |
36 | /// Chain this channel to a FormattingChannel with an |
37 | /// appropriate Formatter to control what is contained |
38 | /// in the text. |
39 | { |
40 | public: |
41 | StreamChannel(std::ostream& str); |
42 | /// Creates the channel. |
43 | |
44 | void log(const Message& msg); |
45 | /// Logs the given message to the channel's stream. |
46 | |
47 | protected: |
48 | virtual ~StreamChannel(); |
49 | |
50 | private: |
51 | std::ostream& _str; |
52 | FastMutex _mutex; |
53 | }; |
54 | |
55 | |
56 | } // namespace Poco |
57 | |
58 | |
59 | #endif // Foundation_StreamChannel_INCLUDED |
60 | |