#include <logmanager.h>
Static Public Member Functions | |
static bool | handleQtMessages () |
static LoggerRepository * | loggerRepository () |
static Logger * | logLogger () |
static Logger * | qtLogger () |
static Logger * | rootLogger () |
static QList< Logger * > | loggers () |
static Level | threshold () |
static void | setThreshold (Level level) |
static void | setHandleQtMessages (bool handleQtMessages) |
static void | configureLogLogger () |
static bool | exists (const char *pName) |
static LogManager * | instance () |
static Logger * | logger (const QString &rName) |
static void | resetConfiguration () |
static void | shutdown () |
static void | startup () |
static const char * | version () |
Related Functions | |
(Note that these are not member functions.) | |
QDebug | operator<< (QDebug debug, const LogManager &rLogManager) |
The LogManager manages logger in a single Hierarchy instance. It provides access to special logger over the logLogger(), qtLogger() and rootLogger() member functions.
The LogManager is handling the initialisation on startup. The initialisation procedure will first attempt to configure the package based on environment variables. If the attempt fails it will check for the existence of configuration files in several location. For detailed description of the initialisation procedure see Initialization procedure.
Messages created by qDebug(), qWarning(), qCritical() and qFatal() can be can be handled by the LogManager. By default the message handling is disabled. It can be enabled by calling setHandleQtMessages(). Once enabled all messages are logged using the logger qtLogger().
The Log4Qt runtime version is accessible over version(). The macros LOG4QT_VERSION and LOG4QT_VERSION_STR provide the compile time version.
bool Log4Qt::LogManager::handleQtMessages | ( | ) | [inline, static] |
Returns if the handling of messages created by calls to qDebug(), qWarning(), qCritical() and qFatal() is activated.
References instance(), and mHandleQtMessages.
LoggerRepository * Log4Qt::LogManager::loggerRepository | ( | ) | [inline, static] |
References instance(), and mpLoggerRepository.
Logger * Log4Qt::LogManager::logLogger | ( | ) | [inline, static] |
Returns the logger used for logging internal messages. See Logging within the package for more details.
Calling this function is equivalent to calling logger("Log4Qt").
References logger().
Logger * Log4Qt::LogManager::qtLogger | ( | ) | [inline, static] |
Returns a pointer to the logger used for logging messages created by calls to qDebug(), qWarning(), qCritical() and qFatal().
Calling this function is equivalent to calling logger("Qt").
References logger().
static Logger* Log4Qt::LogManager::rootLogger | ( | ) | [static] |
static QList<Logger*> Log4Qt::LogManager::loggers | ( | ) | [static] |
static Level Log4Qt::LogManager::threshold | ( | ) | [static] |
static void Log4Qt::LogManager::setThreshold | ( | Level | level | ) | [static] |
void Log4Qt::LogManager::setHandleQtMessages | ( | bool | handleQtMessages | ) | [inline, static] |
Activates or deactivates the handling of messages created by calls to qDebug(), qWarning(), qCritical() and qFatal() is activated.
If activated, a Qt message handler is installed. Messages are logged using the logger returned by qtLogger(). For fatal messages the same exit procedure is implemented as for qFatal().
The following mappping is used from QtMsgType to Level:
QtMsgType | Level |
---|---|
QtDebugMsg | Level::DEBUG_INT |
QtWarningMsg | Level::WARN_INT |
QtCriticalMsg | Level::ERROR_INT |
QtFatalMsg | Level::FATAL_INT |
QtSystemMsg | Level::TRACE_INT |
The default value is false for not handling Qt messages.
References doSetHandleQtMessages(), and instance().
void Log4Qt::LogManager::configureLogLogger | ( | ) | [inline, static] |
Configures the logging for the package to its default behaviour.
The logger logLogger() is configured to be not additive. Messages with the level Level::ERROR_INT and Level::FATAL_INT are written to stderr
using a ConsoleAppender. The remaining messages are written to stdout
using a second ConsoleAppender. The level is read from the system environment or application settings using InitialisationHelper::setting() with the key Debug
. If a level value is found, but it is not a valid Level string, Level::DEBUG_INT is used. If no level string is found Level::ERROR_INT is used.
The function does not remove any appender from the logger logLogger().
References doConfigureLogLogger(), and instance().
static bool Log4Qt::LogManager::exists | ( | const char * | pName | ) | [static] |
static LogManager* Log4Qt::LogManager::instance | ( | ) | [static] |
Returns the LogManager instance.
Referenced by configureLogLogger(), handleQtMessages(), loggerRepository(), setHandleQtMessages(), and startup().
static Logger* Log4Qt::LogManager::logger | ( | const QString & | rName | ) | [static] |
Referenced by logLogger(), and qtLogger().
static void Log4Qt::LogManager::resetConfiguration | ( | ) | [static] |
Reset all values contained in logger repository to their default.
All appenders are removed from all loggers. The loggers are handled in no particular order. The last loggers to be reset are qtLogger(), logLogger() and rootLogger() in that order.
The handling of messages created by calls to qDebug(), qWarning(), qCritical() and qFatal() is deactivated.
The internal logging is initialised to its default bahaviour using configureLogLogger().
static void Log4Qt::LogManager::shutdown | ( | ) | [static] |
void Log4Qt::LogManager::startup | ( | ) | [inline, static] |
Executes the default initialisation procedure of the package.
The function will test for the setting DefaultInitOverride
in the system environment and application settings using InitialisationHelper::setting(). If the value is present and set to anything else then false
, the initialisation is aborted.
The system environment and application settings are tested for the setting Configuration
. If it is found and it is a valid path to a file, the package is configured with the file using PropertyConfigurator::doConfigure(). If the setting Configuration
is not available and a QCoreApplication object is present, the application settings are tested for a group Log4Qt/Properties
. If the group exists, the package is configured with the setting using the PropertyConfiguratordoConfigure(). If neither a configuration file nor configuration settings could be found, the current working directory is searched for the file "log4qt.properties"
. If it is found, the package is configured with the file using PropertyConfigurator::doConfigure().
References doStartup(), and instance().
static const char* Log4Qt::LogManager::version | ( | ) | [static] |
Returns the version number of Log4Qt at run-time. This may be a different version than the version the application was compiled against.
QDebug operator<< | ( | QDebug | debug, | |
const LogManager & | rLogManager | |||
) | [related] |
Writes all object member variables to the given debug stream rDebug and returns the stream.
LogManager(loggerrepository:Hierarchy(loggers:6 root-level:"DEBUG" root-appenders:0 log-level: "NULL" log-appenders:0 qt-level: "NULL" qt-appenders:0 handleqtmessages: false )