log4cpp 1.1
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all 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:
log4cpp::Category

Public Member Functions

 FixedContextCategory (const std::string &name, const std::string &context="")
 Constructor.
 
virtual ~FixedContextCategory ()
 Destructor for Category.
 
virtual void setContext (const std::string &context)
 Set the context string used as NDC.
 
virtual std::string getContext () const
 Return the context string used as NDC.
 
virtual Priority::Value getPriority () const LOG4CPP_NOTHROW
 Returns the assigned Priority, if any, for this Category.
 
virtual Priority::Value getChainedPriority () const LOG4CPP_NOTHROW
 Starting from this Category, search the category hierarchy for a set priority and return it.
 
virtual void addAppender (Appender *appender) LOG4CPP_NOTHROW
 For the moment this method does nothing.
 
virtual void addAppender (Appender &appender)
 For the moment this method does nothing.
 
virtual AppendergetAppender () const
 Returns the Appender for this Category, or NULL if no Appender has been set.
 
virtual AppendergetAppender (const std::string &name) const
 Returns the specified Appender for this Category, or NULL if the Appender is not attached to this Category.
 
virtual AppenderSet getAllAppenders () const
 Returns the set of Appenders currently attached to this Catogory.
 
virtual void removeAllAppenders ()
 Removes all appenders set for this Category.
 
virtual bool ownsAppender () const LOG4CPP_NOTHROW
 FixedContextAppenders cannot own Appenders.
 
virtual bool ownsAppender (Appender *appender) const LOG4CPP_NOTHROW
 FixedContextAppenders cannot own Appenders.
 
virtual void callAppenders (const LoggingEvent &event) LOG4CPP_NOTHROW
 Call the appenders in the hierarchy starting at this.
 
virtual void setAdditivity (bool additivity)
 Set the additivity flag for this Category instance.
 
virtual bool getAdditivity () const LOG4CPP_NOTHROW
 Returns the additivity flag for this Category instance.
 
- Public Member Functions inherited from log4cpp::Category
virtual ~Category ()
 Destructor for Category.
 
virtual const std::string & getName () const LOG4CPP_NOTHROW
 Return the category name.
 
virtual void setPriority (Priority::Value priority)
 Set the priority of this Category.
 
virtual bool isPriorityEnabled (Priority::Value priority) const LOG4CPP_NOTHROW
 Returns true if the chained priority of the Category is equal to or higher than given priority.
 
void setAppender (Appender *appender)
 Adds an Appender to this Category.
 
void setAppender (Appender &appender)
 Adds an Appender for this Category.
 
virtual void removeAppender (Appender *appender)
 Removes specified appender for this Category.
 
virtual CategorygetParent () LOG4CPP_NOTHROW
 Returns the parent category of this category, or NULL if the category is the root category.
 
virtual const CategorygetParent () const LOG4CPP_NOTHROW
 Returns the parent category of this category, or NULL if the category is the root category.
 
virtual void log (Priority::Value priority, const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with the specified priority.
 
virtual void log (Priority::Value priority, const std::string &message) LOG4CPP_NOTHROW
 Log a message with the specified priority.
 
virtual void logva (Priority::Value priority, const char *stringFormat, va_list va) LOG4CPP_NOTHROW
 Log a message with the specified priority.
 
void debug (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with debug priority.
 
void debug (const std::string &message) LOG4CPP_NOTHROW
 Log a message with debug priority.
 
bool isDebugEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority DEBUG.
 
CategoryStream debugStream ()
 Return a CategoryStream with priority DEBUG.
 
void info (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with info priority.
 
void info (const std::string &message) LOG4CPP_NOTHROW
 Log a message with info priority.
 
bool isInfoEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority INFO.
 
CategoryStream infoStream ()
 Return a CategoryStream with priority INFO.
 
void notice (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with notice priority.
 
void notice (const std::string &message) LOG4CPP_NOTHROW
 Log a message with notice priority.
 
bool isNoticeEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority NOTICE.
 
CategoryStream noticeStream ()
 Return a CategoryStream with priority NOTICE.
 
void warn (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with warn priority.
 
void warn (const std::string &message) LOG4CPP_NOTHROW
 Log a message with warn priority.
 
bool isWarnEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority WARN.
 
CategoryStream warnStream ()
 Return a CategoryStream with priority WARN.
 
void error (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with error priority.
 
void error (const std::string &message) LOG4CPP_NOTHROW
 Log a message with error priority.
 
bool isErrorEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority ERROR.
 
CategoryStream errorStream ()
 Return a CategoryStream with priority ERROR.
 
void crit (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with crit priority.
 
void crit (const std::string &message) LOG4CPP_NOTHROW
 Log a message with crit priority.
 
bool isCritEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority CRIT.
 
CategoryStream critStream ()
 Return a CategoryStream with priority CRIT.
 
void alert (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with alert priority.
 
void alert (const std::string &message) LOG4CPP_NOTHROW
 Log a message with alert priority.
 
bool isAlertEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority ALERT.
 
CategoryStream alertStream () LOG4CPP_NOTHROW
 Return a CategoryStream with priority ALERT.
 
void emerg (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with emerg priority.
 
void emerg (const std::string &message) LOG4CPP_NOTHROW
 Log a message with emerg priority.
 
bool isEmergEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority EMERG.
 
CategoryStream emergStream ()
 Return a CategoryStream with priority EMERG.
 
void fatal (const char *stringFormat,...) LOG4CPP_NOTHROW
 Log a message with fatal priority.
 
void fatal (const std::string &message) LOG4CPP_NOTHROW
 Log a message with fatal priority.
 
bool isFatalEnabled () const LOG4CPP_NOTHROW
 Return true if the Category will log messages with priority FATAL.
 
CategoryStream fatalStream ()
 Return a CategoryStream with priority FATAL.
 
virtual CategoryStream getStream (Priority::Value priority)
 Return a CategoryStream with given Priority.
 
virtual CategoryStream operator<< (Priority::Value priority)
 Return a CategoryStream with given Priority.
 

Protected Member Functions

virtual void _logUnconditionally2 (Priority::Value priority, const std::string &message) LOG4CPP_NOTHROW
 Unconditionally log a message with the specified priority.
 
- Protected Member Functions inherited from log4cpp::Category
 Category (const std::string &name, Category *parent, Priority::Value priority=Priority::NOTSET)
 Constructor.
 
virtual void _logUnconditionally (Priority::Value priority, const char *format, va_list arguments) LOG4CPP_NOTHROW
 

Additional Inherited Members

- Static Public Member Functions inherited from log4cpp::Category
static CategorygetRoot ()
 Return the root of the Category hierarchy.
 
static void setRootPriority (Priority::Value priority)
 Set the priority of the root Category.
 
static Priority::Value getRootPriority () LOG4CPP_NOTHROW
 Get the priority of the root Category.
 
static CategorygetInstance (const std::string &name)
 Instantiate a Category with name name.
 
static Categoryexists (const std::string &name)
 If the named category exists (in the default hierarchy) then it returns a reference to the category, otherwise it returns NULL.
 
static std::vector< Category * > * getCurrentCategories ()
 Returns all the currently defined categories as a vector of Category pointers.
 
static void shutdown ()
 This method will remove all Appenders from Categories.XXX.
 
static void shutdownForced ()
 This method will remove all Appenders from Categories.XXX and delete all appenders.
 

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

◆ FixedContextCategory()

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

Constructor.

Parameters
namethe fully qualified name of this Categories delegate Category.
contextthe context to fill the NDC field of LoggingEvents with.

◆ ~FixedContextCategory()

log4cpp::FixedContextCategory::~FixedContextCategory ( )
virtual

Destructor for Category.

Member Function Documentation

◆ _logUnconditionally2()

void log4cpp::FixedContextCategory::_logUnconditionally2 ( Priority::Value priority,
const std::string & message )
protectedvirtual

Unconditionally log a message with the specified priority.

Parameters
priorityThe priority of this log message.
messagestring to write in the log file

Reimplemented from log4cpp::Category.

◆ addAppender() [1/2]

void log4cpp::FixedContextCategory::addAppender ( Appender & appender)
virtual

For the moment this method does nothing.

Reimplemented from log4cpp::Category.

◆ addAppender() [2/2]

void log4cpp::FixedContextCategory::addAppender ( Appender * appender)
virtual

For the moment this method does nothing.

Reimplemented from log4cpp::Category.

◆ callAppenders()

void log4cpp::FixedContextCategory::callAppenders ( const LoggingEvent & event)
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
eventThe LoggingEvent to log.

Reimplemented from log4cpp::Category.

◆ getAdditivity()

bool log4cpp::FixedContextCategory::getAdditivity ( ) const
virtual

Returns the additivity flag for this Category instance.

Reimplemented from log4cpp::Category.

◆ getAllAppenders()

AppenderSet log4cpp::FixedContextCategory::getAllAppenders ( ) const
virtual

Returns the set of Appenders currently attached to this Catogory.

Since
0.3.1
Returns
The set of attached Appenders.

Reimplemented from log4cpp::Category.

◆ getAppender() [1/2]

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.

◆ getAppender() [2/2]

Appender * log4cpp::FixedContextCategory::getAppender ( const std::string & name) const
virtual

Returns the specified Appender for this Category, or NULL if the Appender is not attached to this Category.

Since
0.2.7
Returns
The Appender.

Reimplemented from log4cpp::Category.

◆ getChainedPriority()

Priority::Value log4cpp::FixedContextCategory::getChainedPriority ( ) const
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.

◆ getContext()

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

Return the context string used as NDC.

Returns
the context string.

◆ getPriority()

Priority::Value log4cpp::FixedContextCategory::getPriority ( ) const
virtual

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

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

Reimplemented from log4cpp::Category.

◆ ownsAppender() [1/2]

bool log4cpp::FixedContextCategory::ownsAppender ( ) const
virtual

FixedContextAppenders cannot own Appenders.

Returns
false

Reimplemented from log4cpp::Category.

◆ ownsAppender() [2/2]

bool log4cpp::FixedContextCategory::ownsAppender ( Appender * appender) const
virtual

FixedContextAppenders cannot own Appenders.

Returns
false

Reimplemented from log4cpp::Category.

◆ removeAllAppenders()

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.

◆ setAdditivity()

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

Set the additivity flag for this Category instance.

Reimplemented from log4cpp::Category.

◆ setContext()

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

Set the context string used as NDC.

Parameters
contextthe context string

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