2023-02-08 11:04:11 +00:00
|
|
|
//
|
|
|
|
// StreamChannel.h
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Logging
|
|
|
|
// Module: StreamChannel
|
|
|
|
//
|
|
|
|
// Definition of the StreamChannel class.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Foundation_StreamChannel_INCLUDED
|
|
|
|
#define Foundation_StreamChannel_INCLUDED
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
#include <ostream>
|
2023-02-08 11:04:11 +00:00
|
|
|
#include "Poco/Channel.h"
|
2023-02-13 09:22:33 +00:00
|
|
|
#include "Poco/Foundation.h"
|
2023-02-08 11:04:11 +00:00
|
|
|
#include "Poco/Mutex.h"
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
class Foundation_API StreamChannel : public Channel
|
|
|
|
/// A channel that writes to an ostream.
|
|
|
|
///
|
|
|
|
/// Only the message's text is written, followed
|
|
|
|
/// by a newline.
|
|
|
|
///
|
|
|
|
/// Chain this channel to a FormattingChannel with an
|
|
|
|
/// appropriate Formatter to control what is contained
|
|
|
|
/// in the text.
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-02-13 09:22:33 +00:00
|
|
|
StreamChannel(std::ostream & str);
|
|
|
|
/// Creates the channel.
|
|
|
|
|
|
|
|
void log(const Message & msg);
|
|
|
|
/// Logs the given message to the channel's stream.
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
protected:
|
2023-02-13 09:22:33 +00:00
|
|
|
virtual ~StreamChannel();
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
private:
|
2023-02-13 09:22:33 +00:00
|
|
|
std::ostream & _str;
|
|
|
|
FastMutex _mutex;
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|
|
|
|
|
|
|
|
|
|
|
|
#endif // Foundation_StreamChannel_INCLUDED
|