StreamChannel.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef Foundation_StreamChannel_INCLUDED
  16. #define Foundation_StreamChannel_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include "Poco/Channel.h"
  19. #include "Poco/Mutex.h"
  20. #include <ostream>
  21. namespace Poco {
  22. class Foundation_API StreamChannel: public Channel
  23. /// A channel that writes to an ostream.
  24. ///
  25. /// Only the message's text is written, followed
  26. /// by a newline.
  27. ///
  28. /// Chain this channel to a FormattingChannel with an
  29. /// appropriate Formatter to control what is contained
  30. /// in the text.
  31. {
  32. public:
  33. StreamChannel(std::ostream& str);
  34. /// Creates the channel.
  35. void log(const Message& msg);
  36. /// Logs the given message to the channel's stream.
  37. protected:
  38. virtual ~StreamChannel();
  39. private:
  40. std::ostream& _str;
  41. FastMutex _mutex;
  42. };
  43. } // namespace Poco
  44. #endif // Foundation_StreamChannel_INCLUDED