FormattingChannel.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // FormattingChannel.h
  3. //
  4. // $Id: //poco/1.4/Foundation/include/Poco/FormattingChannel.h#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Logging
  8. // Module: Formatter
  9. //
  10. // Definition of the FormattingChannel 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_FormattingChannel_INCLUDED
  18. #define Foundation_FormattingChannel_INCLUDED
  19. #include "Poco/Foundation.h"
  20. #include "Poco/Channel.h"
  21. namespace Poco {
  22. class Formatter;
  23. class Foundation_API FormattingChannel: public Channel
  24. /// The FormattingChannel is a filter channel that routes
  25. /// a Message through a Formatter before passing it on
  26. /// to the destination channel.
  27. {
  28. public:
  29. FormattingChannel();
  30. /// Creates a FormattingChannel.
  31. FormattingChannel(Formatter* pFormatter);
  32. /// Creates a FormattingChannel and attaches a Formatter.
  33. FormattingChannel(Formatter* pFormatter, Channel* pChannel);
  34. /// Creates a FormattingChannel and attaches a Formatter
  35. /// and a Channel.
  36. void setFormatter(Formatter* pFormatter);
  37. /// Sets the Formatter used to format the messages
  38. /// before they are passed on. If null, the message
  39. /// is passed on unmodified.
  40. Formatter* getFormatter() const;
  41. /// Returns the Formatter used to format messages,
  42. /// which may be null.
  43. void setChannel(Channel* pChannel);
  44. /// Sets the destination channel to which the formatted
  45. /// messages are passed on.
  46. Channel* getChannel() const;
  47. /// Returns the channel to which the formatted
  48. /// messages are passed on.
  49. void log(const Message& msg);
  50. /// Formats the given Message using the Formatter and
  51. /// passes the formatted message on to the destination
  52. /// Channel.
  53. void setProperty(const std::string& name, const std::string& value);
  54. /// Sets or changes a configuration property.
  55. ///
  56. /// Only the "channel" and "formatter" properties are supported, which allow
  57. /// setting the target channel and formatter, respectively, via the LoggingRegistry.
  58. /// The "channel" and "formatter" properties are set-only.
  59. ///
  60. /// Unsupported properties are passed to the attached Channel.
  61. void open();
  62. /// Opens the attached channel.
  63. void close();
  64. /// Closes the attached channel.
  65. protected:
  66. ~FormattingChannel();
  67. private:
  68. Formatter* _pFormatter;
  69. Channel* _pChannel;
  70. };
  71. } // namespace Poco
  72. #endif // Foundation_FormattingChannel_INCLUDED