#include <log.hh>
Inheritance diagram for Qmms::Log::PropertyConfigurator::
Public Methods | |
PropertyConfigurator () | |
Constructor does nothing. More... | |
~PropertyConfigurator () | |
Destructor does nothing. More... | |
Static Public Methods | |
void | configure () |
Configures the qmmslog system from the file whose name is held in the const static string DEFAULT_PROPERTIES. More... | |
void | configure (const QString filename) |
Same as configure(), except it reads the given properties file. More... | |
void | configureWQt () |
Configures the qmmslog system from the default properties, and routes Qt debugging output (qDebug, qWarn, qFatal) through qmmslog. More... | |
void | configureWQt (const QString filename) |
Same as configureWQt(), but uses the given filename for the configuration. More... | |
void | summarize () |
Static Protected Methods | |
void | parseFile (const QString filename) |
Parses the given file into a StrListMap. More... | |
void | addLevels () |
Iterates through the propMap, looking for the "qmmslog.level" key. More... | |
void | parseAppenders () |
Iterates through the propMap and creates the specified appenders. More... | |
bool | verifyAppenderExists (QString name) |
Checks whether the named appender is in the QDict of appenders. More... | |
void | configureRoot () |
Creates and configures the Root Category. More... | |
void | parseCategories () |
Creates and configures all the Categories (except for Root). More... | |
void | configureInternalLogging () |
Configure internal logging system (LogLog). More... | |
Static Protected Attributes | |
AppDict | apdrDict |
A QDict of appenders used to store pointers to all the Appenders created by PropertyConfigurator. More... | |
StrListMap | propMap |
A QMap with QStrings as keys, and QStringLists as values. More... | |
Static Private Attributes | |
const QString | CATEGORY_PREFIX |
The string "qmmslog.category". More... | |
const QString | ROOTCATEGORY_PREFIX |
The string "qmmslog.rootCategory". More... | |
const QString | APPENDER_PREFIX |
The string "qmmslog.appender". More... | |
const QString | LEVEL_PREFIX |
The string "qmmslog.level". More... | |
const QString | DEFAULT_PROPERTIES |
The string ".qmmslogrc". More... | |
const QString | DEBUG_PREFIX |
The string "qmmslog.debug". More... |
This file must be in the following format:
qmmslog.appender.<appenderName>=<fully-qualified-appender-class-name> qmmslog.appender.<appenderName>.layout=<fully-qualified-layout-class-name> qmmslog.appender.<appenderName>.layout.pattern=<pattern string> qmmslog.appender.<appenderName>.filename=<file-to-log-to>[, <file-to-log-to>, ...] qmmslog.appender.<appenderName>.threshold=<threshold> (etc for any other appenders) qmmslog.rootCategory=[<level>, <appender-name>, <appender-name> , ...] qmmslog.category.<category-name>=[level,]<appender-name>, <appender-name>, ...Note that one need not specify the root category, since qmmslog sets the level of the root category to DEBUG and attaches no appenders, by default. Also, appender names are restricted to the chars [a-z], [A-Z], [0-9], while category names can use any char.
E.g., foo.bar is a valid category name and A2 is a valid appender, but the string A:2 is not allowed for an appender name.
After writing a properties file, one need only invoke the static method configure() to setup qmmslog.
What follows is an example .qmmslogrc file.
# Sample qmmslog properties file # First configure the internal logging system (LogLog) (optional -- default is false) qmmslog.debug=true # Then set quietMode for LogLog, if desired (default is false) qmmslog.debug.quietmode=true # Then make any additional levels (optional), like this: # <level-name>, <level-value>, ... qmmslog.level=BAD_ERROR, 450, BIG_WARN, 350 # Then make an appender, using the fully-qualified class name of # the appender's class. The appender's name may contain only # [a-z], [A-Z], or [0-9]. Here the name is A1. qmmslog.appender.A1=Qmms::Log::ConsoleAppender # Then make its layout, again using a FQCN. qmmslog.appender.A1.layout=Qmms::Log::PatternLayout # Then set any options necessary for the layout. qmmslog.appender.A1.layout.pattern=/d /c /p /m /n # Then set any options for the specific type of layout. qmmslog.appender.A1.layout.pattern.datetimeformat=dd MMM yyyy hh:mm # Of course, one could just use a simple layout instead. # qmmslog.appender.A1.layout=Qmms::Log::SimpleLayout # Then make the next appender, in the same way. qmmslog.appender.A2=Qmms::Log::RollingFileAppender # If this appender allows options, put them next. qmmslog.appender.A2.filename=/home/max/logs/logfile qmmslog.appender.A2.maxbackups=3 qmmslog.appender.A2.maxfilesize=100000 qmmslog.appender.A2.threshold=WARN # After all the appender's options, make its layout. qmmslog.appender.A2.layout=Qmms::Log::PatternLayout qmmslog.appender.A2.layout.pattern=/d (/C) /c-/p: /m /n # Now try a SyslogAppender qmmslog.appender.A3=Qmms::Log::SyslogAppender # This is the ident parameter in the openlog() call. Usually it is # the name of the program. qmmslog.appender.A3.syslogname=qmmslog test # Define its layout and any layout options qmmslog.appender.A3.layout=Qmms::Log::PatternLayout qmmslog.appender.A3.layout.pattern=/c-/p: /m /n # Now make the root category, with its attached appender(s). # A loglevel is required (for now). The following makes the root category # (and all its children, if their additivity flags are left true) # log to the console and to syslog any event with level DEBUG or higher (i.e., all). qmmslog.rootCategory=DEBUG, A1, A3 # Now make the categories, with their attached appenders # and an optional explicit log level. Note that any char is allowed # in the category name. Note tha tthe first keyword must be either # "INHERIT" or an explicit loglevel, like "ERROR". # If we wish to set the loglevel of a category explicitly: qmmslog.category.cat=WARN # Else do this. The keyword INHERIT must be used here. Note that # we need not specify an appender, since a category can log to all # the appenders attached to its ancestor categories, depending on # whether its additivity flag is set (which it is, by default). qmmslog.category.cat.foo.bar=INHERIT # Or do this to set the Category's additivity flag to false, so that it does # not append to the attached appenders of its parents. NONADDITIVE may be placed # anywhere after the first keyword. qmmslog.category.cat=ERROR,A2,NONADDITIVEThe name of this file by default is
.qmmslogrc
, so when one invokes the configure() method it is this file that is parsed. configure() will also accept a filename, if one wishes to use a differently-named configuration file.
|
Constructor does nothing.
|
|
Destructor does nothing.
|
|
Iterates through the propMap, looking for the "qmmslog.level" key. Adds those values to the level QMap. |
|
Same as configure(), except it reads the given properties file.
|
|
Configures the qmmslog system from the file whose name is held in the const static string DEFAULT_PROPERTIES. Calls the following methods, in order: parsefile, addLevels, parseAppenders, configureRoot, parseCategories Reimplemented from Qmms::Log::BasicConfigurator. |
|
Configure internal logging system (LogLog).
|
|
Creates and configures the Root Category.
|
|
Same as configureWQt(), but uses the given filename for the configuration.
|
|
Configures the qmmslog system from the default properties, and routes Qt debugging output (qDebug, qWarn, qFatal) through qmmslog.
|
|
Iterates through the propMap and creates the specified appenders.
|
|
Creates and configures all the Categories (except for Root).
|
|
Parses the given file into a StrListMap.
|
|
|
|
Checks whether the named appender is in the QDict of appenders.
|
|
A QDict of appenders used to store pointers to all the Appenders created by PropertyConfigurator.
|
|
The string "qmmslog.appender".
|
|
The string "qmmslog.category".
|
|
The string "qmmslog.debug".
|
|
The string ".qmmslogrc".
|
|
The string "qmmslog.level".
|
|
A QMap with QStrings as keys, and QStringLists as values. Used to hold the name=values pairs in the properties file read by this class. |
|
The string "qmmslog.rootCategory".
|