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
27namespace Poco {
28
29
30class 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{
40public:
41 typedef AutoPtr<StreamChannel> Ptr;
42
43 StreamChannel(std::ostream& str);
44 /// Creates the channel.
45
46 void log(const Message& msg);
47 /// Logs the given message to the channel's stream.
48
49protected:
50 virtual ~StreamChannel();
51
52private:
53 std::ostream& _str;
54 FastMutex _mutex;
55};
56
57
58} // namespace Poco
59
60
61#endif // Foundation_StreamChannel_INCLUDED
62