#include <log.hh>
Inheritance diagram for Qmms::Log::Category::
Public Methods | |
~Category () | |
Destructor does nothing. More... | |
bool | isCategory () |
Category * | getParent () const |
Accessor method. More... | |
void | setParent (Category *p) |
Accessor method. More... | |
QString | getFQN () const |
Accessor method. More... | |
void | setFQN (const QString fqn) |
Accessor method. More... | |
bool | getAdditivity () const |
Accessor method. More... | |
void | setAdditivity (const bool atv) |
Accessor method. More... | |
void | setLevel (const QString lvl) |
Accessor method. More... | |
QString | getChainedLevel () |
Returns the inherited category of this category. More... | |
bool | isEnabledFor (const QString lvl) |
Checks whether the category is enabled for the given level. More... | |
void | addAppender (const AppenderSkeleton *apdr) |
Adds the given appender to this category. More... | |
AppenderSkeleton * | getAppender (const QString name) const |
Accessor method. More... | |
bool | removeAppender (AppenderSkeleton *apdr) |
Removes the appender from this category's QDict of appenders. More... | |
bool | removeAppender (QString name) |
Removes the named appender from this category's QDict of appenders. More... | |
bool | contains (const AppenderSkeleton *apdr) const |
Checks if named appender is contained in the QDict of appenders. More... | |
bool | contains (const QString &name) const |
Checks if named appender is contained in the QDict of attached appenders. More... | |
void | callAppenders (LoggingEvent *evnt) |
Appends the given LoggingEvent to all the appenders attached to this Category and all its ancestors, if the category's additivity flag is set. More... | |
void | closeAllAppenders () |
Calls close() on each appender attached to this category. More... | |
void | removeAllAppenders () |
Calls removeAppender() on all Appenders attached to this category. More... | |
AppDict * | getAppenderList () |
Accessor method. More... | |
void | logWithLevel (QString lvl, QString msg) |
Creates a LoggingEvent from the given message and logs it with the given level. More... | |
void | debug (QString msg) |
Calls logWithLevel() with the DEBUG level. More... | |
void | info (QString msg) |
Calls logWithLevel() with the INFO level. More... | |
void | notice (QString msg) |
Calls logWithLevel() with the NOTICE level. More... | |
void | warn (QString msg) |
Calls logWithLevel() with the WARN level. More... | |
void | error (QString msg) |
Calls logWithLevel() with the ERROR level. More... | |
void | fatal (QString msg) |
Calls logWithLevel() with the FATAL level. More... | |
Static Public Methods | |
Category * | getInstance (const QString name, const QString fqn) |
Static method used to get an instance of a named category. More... | |
Category * | getInstance (const QString name) |
Same as above, but with one less argument. More... | |
Hierarchy * | getDefaultHierarchy () |
Static method that returns a pointer to the default Hierarchy. More... | |
Category * | getRootCat () |
Static method that returns a pointer to the root category. More... | |
void | shutdown () |
Calls shutdown() in class Hierarchy. More... | |
Protected Methods | |
Category () | |
Default constructor does nothing. More... | |
Category (const QString name, const QString fqn) | |
The constructor is protected because Categories are never instantiated this way. More... | |
Category (const Category &rhs) | |
Copy constructor is also private. More... | |
QString | getLevel () const |
Accessor method. More... | |
Protected Attributes | |
Category * | parent |
Pointer to parent category of this category. More... | |
QString | FQN |
Fully-qualified classname of class calling the category. More... | |
QString | level |
The assigned loglevel of this category can be null, in which case the category inherits a level from its ancestor(s) in the hierarchy. More... | |
AppDict | appenderList |
QDict of appenders attached to this category. More... | |
bool | additive |
Additivity is set to true by default. More... | |
bool | hasLevel |
Flag to indicate whether this category has a LogLevel explicitly set. More... | |
Static Protected Attributes | |
Hierarchy * | defaultHierarchy |
The hierarchy the categories are in. More... | |
Friends | |
class | Hierarchy |
Hierarchy is a friend class because it needs to call the constructor. More... |
Categories are instantiated using the static method getInstance()
and NEVER by invoking the constructor directly. (Aside: constructors are private for this reason.) Having getInstance()
handle Category instances ensures that the Hierarchy of categories is maintained properly. Specifically, descendants can be created before their ancestors. Some examples would probably be beneficial.
Here is a typical way to use the qmmslog system.
This code can be found in main.cpp, included with this package.
include <iostream>
include <qmms/log.hh>
using namespace std;
using namespace Qmms::Log;
class CatTest
{
public:
Category* cat;
Category* catfoo;
Category* catfoobar;
CatTest()
{
cout << "Creating CatTest" << endl;
catfoobar = Category::getInstance( "cat.foo.bar", typeid(this).name );
cat = Category::getInstance( "cat" );
catfoo = Category::getInstance( "cat.foo", typeid(this).name );
}
~CatTest()
{
cout << "Deleting CatTest" << endl;
}
void test()
{
catfoobar->debug( "This is a debug" );
cat->warn( "This is a warn" );
catfoo->info( "This is an info" );
cat->fatal( "This is a fatal" );
}
};
int main( int argc, char** argv )
{
BasicConfigurator::configure();
CatTest ct;
ct.test();
Category::shutdown();
return 0;
}
|
Default constructor does nothing.
|
|
The constructor is protected because Categories are never instantiated this way.
Use the static method
|
|
Copy constructor is also private. Does not copy the appender list. |
|
Destructor does nothing.
|
|
Adds the given appender to this category.
|
|
Appends the given LoggingEvent to all the appenders attached to this Category and all its ancestors, if the category's additivity flag is set. This method is thread-safe.
|
|
Calls close() on each appender attached to this category.
|
|
Checks if named appender is contained in the QDict of attached appenders.
|
|
Checks if named appender is contained in the QDict of appenders.
|
|
Calls logWithLevel() with the DEBUG level.
|
|
Calls logWithLevel() with the ERROR level.
|
|
Calls logWithLevel() with the FATAL level.
|
|
Accessor method.
|
|
Accessor method.
|
|
Accessor method.
|
|
Returns the inherited category of this category. Examines this category and all its ancestors until one is found with a loglevel explicitly set. The root category always has a level, so this method always returns a value.
|
|
Static method that returns a pointer to the default Hierarchy.
|
|
Accessor method.
|
|
Same as above, but with one less argument.
|
|
Static method used to get an instance of a named category. It simply calls the static method getCatInstance() in class Hierarchy, thus keeping the Hierarchy invisible to the user.
|
|
Accessor method.
Should be used with care, since it will attempt to return a level even if no level exists. That is, check the boolean attribute
|
|
Accessor method.
|
|
Static method that returns a pointer to the root category.
|
|
Calls logWithLevel() with the INFO level.
|
|
Reimplemented from Qmms::Log::BaseCategory. |
|
Checks whether the category is enabled for the given level. It does this by checking that the given level is not less than the inherited level of this category.
|
|
Creates a LoggingEvent from the given message and logs it with the given level.
|
|
Calls logWithLevel() with the NOTICE level.
|
|
Calls removeAppender() on all Appenders attached to this category.
|
|
Removes the named appender from this category's QDict of appenders. Does nothing if named appender does not exist.
|
|
Removes the appender from this category's QDict of appenders.
|
|
Accessor method. Sets the additivity property.
|
|
Accessor method. Sets the fully-qualified class name of the category.
|
|
Accessor method. Explicitly sets the loglevel of this category.
|
|
Accessor method. Sets the parent of this category.
|
|
Calls shutdown() in class Hierarchy. Use this to close the qmmslog system properly. |
|
Calls logWithLevel() with the WARN level.
|
|
Hierarchy is a friend class because it needs to call the constructor.
|
|
Additivity is set to true by default. That is, children inherit the appenders of their ancestors by default. If this variable is set to false then the appenders found in the ancestors of this category are not used. However, the children of this category will inherit the category's appenders, unless the children have their additivity flags set to false as well. |
|
QDict of appenders attached to this category.
|
|
The hierarchy the categories are in.
|
|
Fully-qualified classname of class calling the category.
|
|
Flag to indicate whether this category has a LogLevel explicitly set.
|
|
The assigned loglevel of this category can be null, in which case the category inherits a level from its ancestor(s) in the hierarchy.
|
|
Pointer to parent category of this category.
|