Log4Qt::InitialisationHelper Class Reference

The class InitialisationHelper performs static initialisation tasks. More...

#include <initialisationhelper.h>

List of all members.

Static Public Member Functions

static QHash< QString, QString > environmentSettings ()
static InitialisationHelperinstance ()
static QString setting (const QString &rKey, const QString &rDefault=QString())
static qint64 startTime ()

Friends

QDebug operator<< (QDebug debug, const InitialisationHelper &rInitialisationHelper)


Detailed Description

The class InitialisationHelper performs static initialisation tasks.

The InitialisationHelper is either created on the first call or through static initialisation. It will capture the programs startup time, which can be retrieved using startTime(). The system environment is analysed for package related definitions. The result is available over environmentSettings(). The packages custom types are registered with the Qt type system.

Settings for the package can be retrieved using setting(). Two macros are available to help with the creation of singletons / global static objects (LOG4QT_GLOBAL_STATIC and LOG4QT_IMPLEMENT_INSTANCE).

Note:
All the functions declared in this class are thread-safe.
See also:
Initialization procedure,

Member Function Documentation

QHash< QString, QString > Log4Qt::InitialisationHelper::environmentSettings (  )  [inline, static]

Returns a hash with the settings retrieved from the system environment on startup.

The following table shows the environment variables taken into account and the setting key used for them.

Environment variable Setting key
LOG4QT_DEBUG Debug
LOG4QT_DEFAULTINITOVERRIDE DefaultInitOverride
LOG4QT_CONFIGURATION Configuration
LOG4QT_CONFIGURATORCLASS ConfiguratorClass

See also:
Environment Variables, setting()

References instance(), and mEnvironmentSettings.

static InitialisationHelper* Log4Qt::InitialisationHelper::instance (  )  [static]

Returns the InitialisationHelper instance.

Referenced by environmentSettings(), setting(), and startTime().

QString Log4Qt::InitialisationHelper::setting ( const QString &  rKey,
const QString &  rDefault = QString() 
) [inline, static]

Returns the value for the setting rKey or rDefault, if it is not defined.

A setting can be either defined by an environment variable or by a key in the application setting. The function will first test the settings made by environment variables for the key rKey using environmentSettings(). If the key is not present and a QCoreApplication exists, the application settings are tested for the key rKey in the group Log4Qt.

The following setting exists:

Setting key Description
Debug The variable controls the Level value for the logger LogManager::logLogger(). If the value is a valid Level string, the level for the logger is set to the level. If the value is not a valid Level string, DEBUG_INT is used. Otherwise ERROR_INT is used.
DefaultInitOverride The variable controls the initialization procedure performed by the LogManager on startup. If it is set to any other value then false the initialization procedure is skipped.
Configuration Specifies the configuration file used for initialising the package.
ConfiguratorClass Specifies the configurator class used for initialising the package.

See also:
environmentSettings(), Environment Variables, Initialization procedure, LogManager::configureLogLogger(), LogManager::startup()

References doSetting(), and instance().

qint64 Log4Qt::InitialisationHelper::startTime (  )  [inline, static]

Returns the start time of the program as the number of milliseconds that have passed since 1970-01-01T00:00:00,000, Coordinated Universal Time (Qt::UTC).

See also:
DateTime::fromMilliSeconds(), DateTime::toMilliSeconds()

References instance(), and mStartTime.


Friends And Related Function Documentation

QDebug operator<< ( QDebug  debug,
const InitialisationHelper rInitialisationHelper 
) [friend]

Writes all object member variables to the given debug stream rDebug and returns the stream.

InitialisationHelper(InitialisationHelper(starttime:1193883677438( QDateTime("Wed Oct 31 21:21:17 2007") ) environmentsettings: QHash(("configuration", "\myapp.log4j") ("Debug", "DEBUG")) ) )

See also:
QDebug, InitialisationHelper::logManager()


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

Generated on Sun Mar 1 16:40:45 2009 for Log4Qt by  doxygen 1.5.6