class Poco::WindowsColorConsoleChannel
Overview
A channel that writes to the Windows console. More…
#include <WindowsConsoleChannel.h> class WindowsColorConsoleChannel: public Poco::Channel { public: // methods virtual void log(const Message& msg); virtual void setProperty( const std::string& name, const std::string& value ); virtual std::string getProperty(const std::string& name) const; protected: // enums enum Color; // methods WORD parseColor(const std::string& color) const; std::string formatColor(WORD color) const; void initColors(); };
Inherited Members
public: // methods virtual void setProperty( const std::string& name, const std::string& value ) = 0; virtual std::string getProperty(const std::string& name) const = 0; void duplicate() const; void release() const; int referenceCount() const; virtual void open(); virtual void close(); virtual void log(const Message& msg) = 0; virtual void setProperty( const std::string& name, const std::string& value ); virtual std::string getProperty(const std::string& name) const;
Detailed Documentation
A channel that writes to the Windows console.
Only the message’s text is written, followed by a newline.
If POCO has been compiled with POCO_WIN32_UTF8, log messages are assumed to be UTF-8 encoded, and are converted to UTF-16 prior to writing them to the console. This is the main difference to the ConsoleChannel class, which cannot handle UTF-8 encoded messages on Windows.
Messages can be colored depending on priority.
To enable message coloring, set the “enableColors” property to true (default). Furthermore, colors can be configured by setting the following properties (default values are given in parenthesis):
* traceColor (gray) * debugColor (gray) * informationColor (default) * noticeColor (default) * warningColor (yellow) * errorColor (lightRed) * criticalColor (lightRed) * fatalColor (lightRed)
The following color values are supported:
* default * black * red * green * brown * blue * magenta * cyan * gray * darkgray * lightRed * lightGreen * yellow * lightBlue * lightMagenta * lightCyan * white
Chain this channel to a FormattingChannel with an appropriate Formatter to control what is contained in the text.
Only available on Windows platforms.
Methods
virtual void log(const Message& msg)
Logs the given message to the channel’s stream.
virtual void setProperty( const std::string& name, const std::string& value )
Sets the property with the given name.
The following properties are supported:
* enableColors: Enable or disable colors. * traceColor: Specify color for trace messages. * debugColor: Specify color for debug messages. * informationColor: Specify color for information messages. * noticeColor: Specify color for notice messages. * warningColor: Specify color for warning messages. * errorColor: Specify color for error messages. * criticalColor: Specify color for critical messages. * fatalColor: Specify color for fatal messages.
See the class documentation for a list of supported color values.
virtual std::string getProperty(const std::string& name) const
Returns the value of the property with the given name.
See setProperty() for a description of the supported properties.