activemq-cpp-3.6.0
decaf::util::logging::Handler Class Reference

A Handler object takes log messages from a Logger and exports them. More...

#include <src/main/decaf/util/logging/Handler.h>

Inheritance diagram for decaf::util::logging::Handler:

Public Member Functions

 Handler ()
virtual ~Handler ()
virtual void flush ()=0
 Flush the Handler's output, clears any buffers.
virtual void publish (const LogRecord &record)=0
 Publish the Log Record to this Handler.
virtual bool isLoggable (const LogRecord &record) const
 Check if this Handler would actually log a given LogRecord.
virtual void setFilter (Filter *filter)
 Sets the Filter that this Handler uses to filter Log Records.
virtual FiltergetFilter ()
 Gets the Filter that this Handler uses to filter Log Records.
virtual void setLevel (const Level &value)
 Set the log level specifying which message levels will be logged by this Handler.
virtual Level getLevel ()
 Get the log level specifying which message levels will be logged by this Handler.
virtual void setFormatter (Formatter *formatter)
 Sets the Formatter used by this Handler.
virtual FormattergetFormatter ()
 Gets the Formatter used by this Handler.
virtual void setErrorManager (ErrorManager *errorManager)
 Sets the Formatter used by this Handler.
virtual ErrorManagergetErrorManager ()
 Gets the ErrorManager used by this Handler.
- Public Member Functions inherited from decaf::io::Closeable
virtual ~Closeable ()
virtual void close ()=0
 Closes this object and deallocates the appropriate resources.

Protected Member Functions

void reportError (const std::string &message, decaf::lang::Exception *ex, int code)
 Protected convenience method to report an error to this Handler's ErrorManager.

Detailed Description

A Handler object takes log messages from a Logger and exports them.

It might for example, write them to a console or write them to a file, or send them to a network logging service, or forward them to an OS log, or whatever.

A Handler can be disabled by doing a setLevel(Level.OFF) and can be re-enabled by doing a setLevel with an appropriate level.

Handler classes typically use LogManager properties to set default values for the Handler's Filter, Formatter, and Level. See the specific documentation for each concrete Handler class.

Constructor & Destructor Documentation

decaf::util::logging::Handler::Handler ( )
virtual decaf::util::logging::Handler::~Handler ( )
virtual

Member Function Documentation

virtual void decaf::util::logging::Handler::flush ( )
pure virtual

Flush the Handler's output, clears any buffers.

Implemented in decaf::util::logging::StreamHandler.

virtual ErrorManager* decaf::util::logging::Handler::getErrorManager ( )
inlinevirtual

Gets the ErrorManager used by this Handler.

Returns
ErrorManager derived pointer or NULL.
virtual Filter* decaf::util::logging::Handler::getFilter ( )
inlinevirtual

Gets the Filter that this Handler uses to filter Log Records.

Returns
Filter derived instance
virtual Formatter* decaf::util::logging::Handler::getFormatter ( )
inlinevirtual

Gets the Formatter used by this Handler.

Returns
Filter derived instance
virtual Level decaf::util::logging::Handler::getLevel ( )
inlinevirtual

Get the log level specifying which message levels will be logged by this Handler.

Returns
Level enumeration value
virtual bool decaf::util::logging::Handler::isLoggable ( const LogRecord record) const
virtual

Check if this Handler would actually log a given LogRecord.

This method checks if the LogRecord has an appropriate Level and whether it satisfies any Filter. It also may make other Handler specific checks that might prevent a handler from logging the LogRecord.

Parameters
recordLogRecord to check

Reimplemented in decaf::util::logging::StreamHandler.

virtual void decaf::util::logging::Handler::publish ( const LogRecord record)
pure virtual

Publish the Log Record to this Handler.

Parameters
recordThe Log Record to Publish

Implemented in decaf::util::logging::StreamHandler, and decaf::util::logging::ConsoleHandler.

void decaf::util::logging::Handler::reportError ( const std::string &  message,
decaf::lang::Exception ex,
int  code 
)
protected

Protected convenience method to report an error to this Handler's ErrorManager.

Parameters
message- a descriptive string (may be empty)
ex- an exception (may be NULL)
code- an error code defined in ErrorManager
virtual void decaf::util::logging::Handler::setErrorManager ( ErrorManager errorManager)
virtual

Sets the Formatter used by this Handler.

The ErrorManager's "error" method will be invoked if any errors occur while using this Handler.

Parameters
errorManagerErrorManager derived instance
virtual void decaf::util::logging::Handler::setFilter ( Filter filter)
inlinevirtual

Sets the Filter that this Handler uses to filter Log Records.

For each call of publish the Handler will call this Filter (if it is non-null) to check if the LogRecord should be published or discarded.

Parameters
filterFilter derived instance
virtual void decaf::util::logging::Handler::setFormatter ( Formatter formatter)
virtual

Sets the Formatter used by this Handler.

Some Handlers may not use Formatters, in which case the Formatter will be remembered, but not used.

Parameters
formatterFilter derived instance
virtual void decaf::util::logging::Handler::setLevel ( const Level value)
inlinevirtual

Set the log level specifying which message levels will be logged by this Handler.

The intention is to allow developers to turn on voluminous logging, but to limit the messages that are sent to certain Handlers.

Parameters
valueLevel enumeration value

The documentation for this class was generated from the following file: