StreamChannel.h 1.2 KB

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