Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

log4cpp::FixedContextCategory Class Reference

This Category subclass replaces the NDC field in LoggingEvents with a fixed context string. More...

#include <FixedContextCategory.hh>

Inheritance diagram for log4cpp::FixedContextCategory:

Inheritance graph
[legend]
Collaboration diagram for log4cpp::FixedContextCategory:

Collaboration graph
[legend]
List of all members.

Public Methods

 FixedContextCategory (const std::string &name, const std::string &context)
 Constructor. More...

virtual ~FixedContextCategory ()
 Destructor for Category.

virtual void setContext (const std::string &context)
 Set the context string used as NDC. More...

virtual std::string getContext () const
 Return the context string used as NDC. More...

virtual Priority::Value getPriority () const throw ()
 Returns the assigned Priority, if any, for this Category. More...

virtual Priority::Value getChainedPriority () const throw ()
 Starting from this Category, search the category hierarchy for a set priority and return it. More...

virtual void setAppender (Appender *appender)
 Sets an Appender for this Category. More...

virtual void setAppender (Appender &appender)
 Sets an Appender for this Category. More...

virtual AppendergetAppender () const
 Returns the Appender for this Category, or NULL if no Appender has been set. More...

virtual void removeAllAppenders ()
 Removes all appenders set for this Category. More...

virtual bool ownsAppender () const throw ()
 Returns true if the Category owns the Appender. More...

virtual void callAppenders (const LoggingEvent &event) throw ()
 Call the appenders in the hierarchy starting at this. More...

virtual void setAdditivity (bool additivity)
 Set the additivity flag for this Category instance.

virtual bool getAdditivity () const throw ()
 Returns the additivity flag for this Category instance.


Protected Methods

virtual void _logUnconditionally2 (Priority::Value priority, const std::string &message) throw ()
 Unconditionally log a message with the specified priority. More...


Detailed Description

This Category subclass replaces the NDC field in LoggingEvents with a fixed context string.

All handling of Appenders, etc. is delgated to the 'normal' Category with the same name. Its intended use is for object instances that serve a single client: they contruct a FixedContextCategory with the client identifier as context. Unlike with regular Category instances one has to explicitly create FixedContextCategory instances using the constructor. This also implies one has to take cake of destruction of the instance as well.

Since:
0.2.4


Constructor & Destructor Documentation

log4cpp::FixedContextCategory::FixedContextCategory ( const std::string & name,
const std::string & context )
 

Constructor.

Parameters:
name   the fully qualified name of this Categories delegate Category.
context   the context to fill the NDC field of LoggingEvents with.
priority   the priority for this Category. Defaults to Priority::NOTSET

log4cpp::FixedContextCategory::~FixedContextCategory ( ) [virtual]
 

Destructor for Category.


Member Function Documentation

void log4cpp::FixedContextCategory::_logUnconditionally2 ( Priority::Value priority,
const std::string & message ) throw () [protected, virtual]
 

Unconditionally log a message with the specified priority.

Parameters:
priority   The priority of this log message.
message   string to write in the log file

Reimplemented from log4cpp::Category.

void log4cpp::FixedContextCategory::callAppenders ( const LoggingEvent & event ) throw () [virtual]
 

Call the appenders in the hierarchy starting at this.

If no appenders could be found, emit a warning.

This method always calls all the appenders inherited form the hierracy circumventing any evaluation of whether to log or not to log the particular log request.

Parameters:
LoggingEvent   the event to log.

Reimplemented from log4cpp::Category.

bool log4cpp::FixedContextCategory::getAdditivity ( ) const throw () [virtual]
 

Returns the additivity flag for this Category instance.

Reimplemented from log4cpp::Category.

Appender * log4cpp::FixedContextCategory::getAppender ( ) const [virtual]
 

Returns the Appender for this Category, or NULL if no Appender has been set.

Returns:
The Appender.

Reimplemented from log4cpp::Category.

Priority::Value log4cpp::FixedContextCategory::getChainedPriority ( ) const throw () [virtual]
 

Starting from this Category, search the category hierarchy for a set priority and return it.

Otherwise, return the priority of the root category.

The Category class is designed so that this method executes as quickly as possible.

Reimplemented from log4cpp::Category.

std::string log4cpp::FixedContextCategory::getContext ( ) const [virtual]
 

Return the context string used as NDC.

Returns:
the context string.

Priority::Value log4cpp::FixedContextCategory::getPriority ( ) const throw () [virtual]
 

Returns the assigned Priority, if any, for this Category.

Returns:
Priority - the assigned Priority, can be Priority::NOTSET

Reimplemented from log4cpp::Category.

bool log4cpp::FixedContextCategory::ownsAppender ( ) const throw () [virtual]
 

Returns true if the Category owns the Appender.

In that case the Category destructor will delete the Appender.

Reimplemented from log4cpp::Category.

void log4cpp::FixedContextCategory::removeAllAppenders ( ) [virtual]
 

Removes all appenders set for this Category.

Currently a Category can have only one appender, but this may change in the future.

Reimplemented from log4cpp::Category.

void log4cpp::FixedContextCategory::setAdditivity ( bool additivity ) [virtual]
 

Set the additivity flag for this Category instance.

Reimplemented from log4cpp::Category.

void log4cpp::FixedContextCategory::setAppender ( Appender & appender ) [virtual]
 

Sets an Appender for this Category.

This method does not pass ownership from the caller to the Category.

Parameters:
appender   The Appender this category has to log to.

Reimplemented from log4cpp::Category.

void log4cpp::FixedContextCategory::setAppender ( Appender * appender ) [virtual]
 

Sets an Appender for this Category.

This method passes ownership from the caller to the Category.

Parameters:
appender   The Appender this category has to log to.

Reimplemented from log4cpp::Category.

void log4cpp::FixedContextCategory::setContext ( const std::string & context ) [virtual]
 

Set the context string used as NDC.

Parameters:
context   the context string


The documentation for this class was generated from the following file:
Generated at Mon Jun 11 01:25:23 2001 for log4cpp by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001