diff options
Diffstat (limited to 'doc/src/index.qdoc')
-rw-r--r-- | doc/src/index.qdoc | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc new file mode 100644 index 0000000..e8dbf6d --- /dev/null +++ b/doc/src/index.qdoc @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of QtLogger +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page index.html + \title QLogger Reference + \brief The Qt Logging API provides the application developer a categorized logging mechanism. + + \section1 Introduction + + The Qt Logging API provides the application developer a categorized logging mechanism. + + + \section1 Overview + + The logging is designed to provide a flexible logging mechanism in an efficent manner. + + + \section1 Features + + + 1. Enable or disable logging without recompiling your project. + + Logging can be activated by providing a logging rules file or providing a QByteArray that contains the + \l {logging_rules} {rules}. + + + 2. Logging with categories + + Developer can create their own logging categories. + + Every category can be turned on or off for logging during runtime. + Each category contains a subset of "debug", "warning" and "critical" subcategories. + In the initialization logging will be performed for all "warning" and "critical" subcategories. + + + \section1 How to Use + + \section2 Add QLogger to Your Project + + First you need to add the QLogger library dependency to your application: + + LIBS += -lQtLogger + + or use + + QT+= logger + + In your application you need to include the QLogger header: + + #include <QtLogger/QtLogger> + + Note: qDebug, qWarning and qCritical getting redefined in this header so make sure that the QLogger header gets included after qlogging.h. + + \section2 Creating Logging Rules + \target logging_rules + + As mentioned above logging rules are needed to control the behavior of the logging. + The logging rules containing basically the categories and a true/false value for each category: + + + Here is an example of some logging rules: + + + \table + \header + \row \li Nokia.driver.usb.debug = true + \row \li Nokia.driver.usb.warning = true + \row \li Nokia.driver.event = false + \endtable + + Of course you could write Nokia.driver.usb = true, this will enable all subcategories (debug, warning and critical). + Vice versa with Nokia.driver.usb = false. + + + \section3 Wildcards + + + Wildcard (*) category definitions are possible as well. The order of the categories in your configuration is important. From top to bottom the category priority is low to high. + e.g: + + \table + \header + \row \li Nokia*=false + \row \li *Nokia=true + \row \li *Nokia*=true + \endtable + + All categories containing the word Nokia will be logged. + Willdcard "*" can only apply to the beginning or/and to the end of your configuration category entry. + + + The usage of qDebug(), qWarning() and qCrititcal results in the category "default". + e.g. + + \table + \header \li Macro \li category + \row \li qDebug \li "default.debug" + \row \li qWarning \li "default.warning" + \row \li qCritical \li "default.critical" + \endtable + + + The logging rule file can be defined by using the environment variable QT_LOGGING_CONFIG. + The application developer can set the rule file by using: + + + qSetLoggingRulesFile(const QString &path) + + + or by defining a QByteArray containing the rules and call: + + + qSetLoggingRules(const QByteArray &configcontent) + + + If there is no configuration available logging will not be performed. + Note: QT_LOGGING_CONFIG will overwrite the qSetLoggingRulesFile and qSetLoggingRules calls. + + + \section2 Logging usage in your project + + Qt provides a macro to create your logging Categories: + + \snippet logger/main.cpp 1 + + In this example a logging category NOKIA_DRIVER_USB with a category string of "Nokia.driver.usb" and NOKIA_DRIVER_EVENT with a category string of "Nokia.driver.event" is created. + In you configuration file you could write: + + \table + \header + \row \li Nokia.driver.usb = true + \row \li Nokia.driver.event = true + \row \li or even: Nokia.driver.* = true + \endtable + + + Next you need to tell Qt where the logging rules configuration file can be found. + + \snippet logger/main.cpp 2 + + In this example the configuration file "mylogging.cfg" is in the current directory. + + A category logging can be done by using the qCDebug(<category>), qCWarning(<category>) or the qCCritical(<category>) macro. + + \snippet logger/main.cpp 3 + + \section1 Default settings + If there is no logging rules defined "debug" subcategories are disabled but "warning" and "critical" are enabled. + + + + \section1 Functions + + + \section2 + qSetLoggingRules(const QByteArray &rules) + + Set the logging rules with the given \a rules byte array. + + + \section2 + qSetLoggingRulesFile(const QString &path) + + Set the config file with the given \a path which contains the logging rules for category logging. + The parameter \a path can contain only the file name. + In this case the standard path for configuration files QStandardPaths will be used. +*/ |