This is the central class in the log4j package. More...
#include <Category.hh>
Public Member Functions | |
virtual void | addAppender (Appender *appender) |
Adds an Appender to this Category. More... | |
virtual void | addAppender (Appender &appender) |
Adds an Appender for this Category. More... | |
void | alert (const char *stringFormat,...) throw () |
Log a message with alert priority. More... | |
void | alert (const std::string &message) throw () |
Log a message with alert priority. More... | |
CategoryStream | alertStream () throw () |
Return a CategoryStream with priority ALERT. More... | |
virtual void | callAppenders (const LoggingEvent &event) throw () |
Call the appenders in the hierarchy starting at this . More... | |
void | crit (const char *stringFormat,...) throw () |
Log a message with crit priority. More... | |
void | crit (const std::string &message) throw () |
Log a message with crit priority. More... | |
CategoryStream | critStream () |
Return a CategoryStream with priority CRIT. More... | |
void | debug (const char *stringFormat,...) throw () |
Log a message with debug priority. More... | |
void | debug (const std::string &message) throw () |
Log a message with debug priority. More... | |
CategoryStream | debugStream () |
Return a CategoryStream with priority DEBUG. More... | |
void | emerg (const char *stringFormat,...) throw () |
Log a message with emerg priority. More... | |
void | emerg (const std::string &message) throw () |
Log a message with emerg priority. More... | |
CategoryStream | emergStream () |
Return a CategoryStream with priority EMERG. More... | |
void | error (const char *stringFormat,...) throw () |
Log a message with error priority. More... | |
void | error (const std::string &message) throw () |
Log a message with error priority. More... | |
CategoryStream | errorStream () |
Return a CategoryStream with priority ERROR. More... | |
void | fatal (const char *stringFormat,...) throw () |
Log a message with fatal priority. More... | |
void | fatal (const std::string &message) throw () |
Log a message with fatal priority. More... | |
CategoryStream | fatalStream () |
Return a CategoryStream with priority FATAL. More... | |
virtual bool | getAdditivity () const throw () |
Returns the additivity flag for this Category instance. More... | |
virtual AppenderSet | getAllAppenders () const |
Returns the set of Appenders currently attached to this Catogory. More... | |
virtual Appender * | getAppender () const |
Returns the first Appender for this Category, or NULL if no Appender has been set. More... | |
virtual Appender * | getAppender (const std::string &name) const |
Returns the specified Appender for this Category, or NULL if the Appender is not attached to 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 const std::string & | getName () const throw () |
Return the category name. More... | |
virtual Category * | getParent () throw () |
Returns the parent category of this category, or NULL if the category is the root category. More... | |
virtual const Category * | getParent () const throw () |
Returns the parent category of this category, or NULL if the category is the root category. More... | |
virtual Priority::Value | getPriority () const throw () |
Returns the assigned Priority, if any, for this Category. More... | |
virtual CategoryStream | getStream (Priority::Value priority) |
Return a CategoryStream with given Priority. More... | |
void | info (const char *stringFormat,...) throw () |
Log a message with info priority. More... | |
void | info (const std::string &message) throw () |
Log a message with info priority. More... | |
void | info_pop (const char *stringFormat,...) throw () |
Log a message with info priority & pops an indentation to the NDC stack. More... | |
void | info_push (const char *stringFormat,...) throw () |
Log a message with info priority & pushes an indentation to the NDC stack. More... | |
CategoryStream | infoStream () |
Return a CategoryStream with priority INFO. More... | |
bool | isAlertEnabled () const throw () |
Return true if the Category will log messages with priority ALERT. More... | |
bool | isCritEnabled () const throw () |
Return true if the Category will log messages with priority CRIT. More... | |
bool | isDebugEnabled () throw () |
Return true if the Category will log messages with priority DEBUG. More... | |
bool | isEmergEnabled () const throw () |
Return true if the Category will log messages with priority EMERG. More... | |
bool | isErrorEnabled () const throw () |
Return true if the Category will log messages with priority ERROR. More... | |
bool | isFatalEnabled () const throw () |
Return true if the Category will log messages with priority FATAL. More... | |
bool | isInfoEnabled () throw () |
Return true if the Category will log messages with priority INFO. More... | |
bool | isNoticeEnabled () const throw () |
Return true if the Category will log messages with priority NOTICE. More... | |
virtual bool | isPriorityEnabled (Priority::Value priority) const throw () |
Returns true if the chained priority of the Category is equal to or higher than given priority. More... | |
bool | isWarnEnabled () throw () |
Return true if the Category will log messages with priority WARN. More... | |
virtual void | log (Priority::Value priority, const char *stringFormat,...) throw () |
Log a message with the specified priority. More... | |
virtual void | log (Priority::Value priority, const std::string &message) throw () |
Log a message with the specified priority. More... | |
virtual void | logva (Priority::Value priority, const char *stringFormat, va_list va) throw () |
Log a message with the specified priority. More... | |
void | notice (const char *stringFormat,...) throw () |
Log a message with notice priority. More... | |
void | notice (const std::string &message) throw () |
Log a message with notice priority. More... | |
CategoryStream | noticeStream () |
Return a CategoryStream with priority NOTICE. More... | |
virtual CategoryStream | operator<< (Priority::Value priority) |
Return a CategoryStream with given Priority. More... | |
virtual bool | ownsAppender () const throw () |
Returns true if the Category owns the first Appender in its Appender set. More... | |
virtual bool | ownsAppender (Appender *appender) const throw () |
Returns true if the Category owns the Appender. More... | |
virtual void | removeAllAppenders () |
Removes all appenders for this Category. More... | |
virtual void | removeAppender (Appender *appender) |
Removes specified appender for this Category. More... | |
virtual void | setAdditivity (bool additivity) |
Set the additivity flag for this Category instance. More... | |
void | setAppender (Appender *appender) |
Adds an Appender to this Category. More... | |
void | setAppender (Appender &appender) |
Adds an Appender for this Category. More... | |
virtual void | setPriority (Priority::Value priority) |
Set the priority of this Category. More... | |
void | warn (const char *stringFormat,...) throw () |
Log a message with warn priority. More... | |
void | warn (const std::string &message) throw () |
Log a message with warn priority. More... | |
CategoryStream | warnStream () |
Return a CategoryStream with priority WARN. More... | |
virtual | ~Category () |
Destructor for Category. More... | |
Static Public Member Functions | |
static Category * | exists (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. More... | |
static std::vector< Category * > * | getCurrentCategories () |
Returns all the currently defined categories as a vector of Category pointers. More... | |
static Category & | getInstance (const std::string &name) |
Instantiate a Category with name name . More... | |
static Category & | getRoot () |
Return the root of the Category hierarchy. More... | |
static Priority::Value | getRootPriority () throw () |
Get the priority of the root Category. More... | |
static void | setRootPriority (Priority::Value priority) |
Set the priority of the root Category. More... | |
static void | shutdown () |
This method will remove all Appenders from Categories.XXX. More... | |
Protected Member Functions | |
virtual void | _logUnconditionally (Priority::Value priority, const char *format, va_list arguments) throw () |
virtual void | _logUnconditionally2 (Priority::Value priority, const std::string &message) throw () |
Unconditionally log a message with the specified priority. More... | |
Category (const std::string &name, Category *parent, Priority::Value priority=Priority::NOTSET) | |
Constructor. More... | |
Private Types | |
typedef std::map< Appender *, bool > | OwnsAppenderMap |
Private Member Functions | |
Category (const Category &other) | |
void | InvalidateEnabledCache (bool InvalidateAll=true) |
Invalidates the enabled caches for the different priorities. More... | |
Category & | operator= (const Category &other) |
virtual bool | ownsAppender (Appender *appender, OwnsAppenderMap::iterator &i2) throw () |
Returns the iterator to the Appender if the Category owns the Appender. More... | |
Private Attributes | |
AppenderSet | _appender |
threading::Mutex | _appenderSetMutex |
bool | _DebugEnabled |
Indicates that logging is enabled for Info level. More... | |
bool | _InfoEnabled |
Indicates that logging is enabled for Info level. More... | |
volatile bool | _isAdditive |
Additivity is set to true by default, i.e. More... | |
const std::string | _name |
The name of this category. More... | |
OwnsAppenderMap | _ownsAppender |
Whether the category holds the ownership of the appender. More... | |
Category * | _parent |
The parent of this category. More... | |
volatile Priority::Value | _priority |
The assigned priority of this category. More... | |
bool | _ValidDebugEnabledCache |
Indicates if the *Enabled flags are valid. More... | |
bool | _ValidInfoEnabledCache |
Indicates if the *Enabled flags are valid. More... | |
bool | _ValidWarnEnabledCache |
Indicates if the *Enabled flags are valid. More... | |
bool | _WarnEnabled |
Indicates that logging is enabled for Info level. More... | |
Friends | |
class | HierarchyMaintainer |
This is the central class in the log4j package.
One of the distintive features of log4j (and hence log4cpp) are hierarchal categories and their evaluation.
Definition at line 34 of file Category.hh.
|
private |
Definition at line 673 of file Category.hh.
|
virtual |
Destructor for Category.
|
protected |
Constructor.
name | the fully qualified name of this Category |
parent | the parent of this parent, or NULL for the root Category |
priority | the priority for this Category. Defaults to Priority::NOTSET |
|
private |
|
protectedvirtual |
|
protectedvirtual |
Unconditionally log a message with the specified priority.
priority | The priority of this log message. |
message | string to write in the log file |
Reimplemented in FixedContextCategory.
|
virtual |
Adds an Appender to this Category.
This method passes ownership from the caller to the Category.
appender | The Appender to wich this category has to log. |
GenICam::InvalidArgumentException | if the appender is NULL. |
Reimplemented in FixedContextCategory.
|
virtual |
Adds an Appender for this Category.
This method does not pass ownership from the caller to the Category.
appender | The Appender this category has to log to. |
Reimplemented in FixedContextCategory.
void Category::alert | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with alert priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::alert | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with alert priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority ALERT.
Definition at line 542 of file Category.hh.
|
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.
event | the LogginEvent to log. |
Reimplemented in FixedContextCategory.
void Category::crit | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with crit priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::crit | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with crit priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority CRIT.
Definition at line 512 of file Category.hh.
void Category::debug | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with debug priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::debug | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with debug priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority DEBUG.
Definition at line 336 of file Category.hh.
void Category::emerg | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with emerg priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::emerg | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with emerg priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority EMERG.
Definition at line 572 of file Category.hh.
void Category::error | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with error priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::error | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with error priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority ERROR.
Definition at line 482 of file Category.hh.
|
static |
If the named category exists (in the default hierarchy) then it returns a reference to the category, otherwise it returns NULL.
void Category::fatal | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with fatal priority.
NB. priority 'fatal' is equivalent to 'emerg'.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::fatal | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with fatal priority.
NB. priority 'fatal' is equivalent to 'emerg'.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority FATAL.
NB. priority 'fatal' is equivalent to 'emerg'.
Definition at line 610 of file Category.hh.
|
virtual |
Returns the additivity flag for this Category instance.
Reimplemented in FixedContextCategory.
|
virtual |
Returns the set of Appenders currently attached to this Catogory.
Reimplemented in FixedContextCategory.
|
virtual |
Returns the first Appender for this Category, or NULL if no Appender has been set.
Reimplemented in FixedContextCategory.
|
virtual |
|
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 in FixedContextCategory.
|
static |
Returns all the currently defined categories as a vector of Category pointers.
Note: this function does not pass ownership of the categories in the vector to the caller, only the ownership of the vector. However vector<Category&>* is not legal C++, so we can't follow the default ownership conventions.
Unlike in log4j, the root category is included in the returned set.
|
static |
Instantiate a Category with name name
.
This method does not set priority of the category which is by default Priority::NOTSET
.
name | The name of the category to retrieve. |
|
virtual |
Return the category name.
|
virtual |
Returns the parent category of this category, or NULL if the category is the root category.
|
virtual |
Returns the parent category of this category, or NULL if the category is the root category.
|
virtual |
Returns the assigned Priority, if any, for this Category.
Reimplemented in FixedContextCategory.
|
static |
Return the root of the Category hierarchy.
The root category is always instantiated and available. It's name is the empty string.
Unlike in log4j, calling Category.getInstance("")
does retrieve the root category and not a category just under root named "".
|
static |
Get the priority of the root
Category.
|
virtual |
Return a CategoryStream with given Priority.
priority | The Priority of the CategoryStream. |
void Category::info | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with info priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::info | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with info priority.
message | string to write in the log file |
void Category::info_pop | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with info priority & pops an indentation to the NDC stack.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::info_push | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with info priority & pushes an indentation to the NDC stack.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
|
inline |
Return a CategoryStream with priority INFO.
Definition at line 387 of file Category.hh.
|
private |
Invalidates the enabled caches for the different priorities.
|
inline |
Return true if the Category will log messages with priority ALERT.
Definition at line 534 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority CRIT.
Definition at line 504 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority DEBUG.
Definition at line 323 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority EMERG.
Definition at line 564 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority ERROR.
Definition at line 474 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority FATAL.
NB. priority 'fatal' is equivalent to 'emerg'.
Definition at line 600 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority INFO.
Definition at line 374 of file Category.hh.
|
inline |
Return true if the Category will log messages with priority NOTICE.
Definition at line 409 of file Category.hh.
|
virtual |
Returns true if the chained priority of the Category is equal to or higher than given priority.
priority | The priority to compare with. |
|
inline |
Return true if the Category will log messages with priority WARN.
Definition at line 439 of file Category.hh.
|
virtual |
Log a message with the specified priority.
priority | The priority of this log message. |
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
|
virtual |
Log a message with the specified priority.
priority | The priority of this log message. |
message | string to write in the log file |
|
virtual |
Log a message with the specified priority.
priority | The priority of this log message. |
stringFormat | Format specifier for the string to write in the log file. |
va | The arguments for stringFormat. |
void Category::notice | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with notice priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::notice | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with notice priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority NOTICE.
Definition at line 417 of file Category.hh.
|
virtual |
Return a CategoryStream with given Priority.
priority | The Priority of the CategoryStream. |
|
inlinevirtual |
Returns true if the Category owns the first Appender in its Appender set.
In that case the Category destructor will delete the Appender.
Reimplemented in FixedContextCategory.
Definition at line 227 of file Category.hh.
|
virtual |
Returns true if the Category owns the Appender.
In that case the Category destructor will delete the Appender.
Reimplemented in FixedContextCategory.
|
privatevirtual |
|
virtual |
Removes all appenders for this Category.
Reimplemented in FixedContextCategory.
|
virtual |
Removes specified appender for this Category.
|
virtual |
Set the additivity flag for this Category instance.
Reimplemented in FixedContextCategory.
|
inline |
Adds an Appender to this Category.
This method passes ownership from the caller to the Category.
appender | The Appender this category has to log to or NULL to remove the current Appenders. |
Definition at line 169 of file Category.hh.
|
inline |
Adds an Appender for this Category.
This method does not pass ownership from the caller to the Category.
appender | The Appender this category has to log to. |
Definition at line 183 of file Category.hh.
|
virtual |
Set the priority of this Category.
priority | The priority to set. Use Priority::NOTSET to let the category use its parents priority as effective priority. |
std::invalid_argument | if the caller tries to set Priority::NOTSET on the Root Category. |
|
static |
|
static |
This method will remove all Appenders from Categories.XXX.
void Category::warn | ( | const char * | stringFormat, |
... | |||
) | |||
throw | ( | ||
) |
Log a message with warn priority.
stringFormat | Format specifier for the string to write in the log file. |
... | The arguments for stringFormat |
void Category::warn | ( | const std::string & | message | ) | |
throw | ( | ||||
) |
Log a message with warn priority.
message | string to write in the log file |
|
inline |
Return a CategoryStream with priority WARN.
Definition at line 452 of file Category.hh.
|
friend |
Definition at line 35 of file Category.hh.
|
private |
Definition at line 684 of file Category.hh.
|
mutableprivate |
Definition at line 685 of file Category.hh.
|
private |
Indicates that logging is enabled for Info level.
Definition at line 710 of file Category.hh.
|
private |
Indicates that logging is enabled for Info level.
Definition at line 704 of file Category.hh.
|
private |
Additivity is set to true by default, i.e.
a child inherits its ancestor's appenders by default.
Definition at line 698 of file Category.hh.
|
private |
The name of this category.
Definition at line 660 of file Category.hh.
|
private |
Whether the category holds the ownership of the appender.
If so, it deletes the appender in its destructor.
Definition at line 692 of file Category.hh.
|
private |
The parent of this category.
All categories have al least one ancestor which is the root category.
Definition at line 666 of file Category.hh.
|
private |
The assigned priority of this category.
Definition at line 671 of file Category.hh.
|
private |
Indicates if the *Enabled flags are valid.
Definition at line 707 of file Category.hh.
|
private |
Indicates if the *Enabled flags are valid.
Definition at line 701 of file Category.hh.
|
private |
Indicates if the *Enabled flags are valid.
Definition at line 713 of file Category.hh.
|
private |
Indicates that logging is enabled for Info level.
Definition at line 716 of file Category.hh.