summaryrefslogtreecommitdiffstats
path: root/doc/src/index.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/index.qdoc')
-rw-r--r--doc/src/index.qdoc75
1 files changed, 51 insertions, 24 deletions
diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc
index 7e9a32b..efaa7e8 100644
--- a/doc/src/index.qdoc
+++ b/doc/src/index.qdoc
@@ -54,9 +54,13 @@
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.
+ See \l {Default settings} .
+
\section1 How to Use
@@ -70,12 +74,14 @@
#include <qlogger.h>
- Note: qDebug, qWarning and qCritical are re-defined by this header.
+ Note: The current implementation re-defines qDebug, qWarning and qCritical by this header.
+
\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:
@@ -90,13 +96,13 @@
\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.
+ 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.
- 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
@@ -106,11 +112,12 @@
\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.
+ In this example 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
@@ -121,26 +128,47 @@
\endtable
- The logging rule file can be defined by using the environment variable \l QT_LOGGING_CONFIG.
- The application developer can set the rule file by using \l qSetLoggingRulesFile() or can
- set the rules directly using \l qSetLoggingRules().
+ \section2 Create your Category Logging Object in your Project
- If there is no configuration available, the \l {Default settings} will be used.
+ There are two different ways to create your own category object.
- \section2 QT_LOGGING_CONFIG
- The QT_LOGGING_CONFIG environment variable overrides both qSetLoggingRulesFile() and
- qSetLoggingRules() if it points to a file.
+ 1. Qt provides the \l QT_LOG_CATEGORY() macro to create your logging Categories:
- If QT_LOGGING_CONFIG is relative, QStandardPaths::writeableLocation(QStandardPaths::ConfigLocation) will be prepended.
+ \snippet logger/main.cpp 1
- \section2 Logging usage in your project
+ 2. You can create your own \l QLoggingCategory object:
- Qt provides the \l QT_LOG_CATEGORY() macro to create your logging Categories:
+ \snippet logger/main.cpp 4
- \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.
+ \section2 Activate Logging Rules
+
+ There are 3 three different way to activate the logging rules:
+
+ \table
+ \header
+ \row \li 1. \li The application developer can set the rule file by using \l qSetLoggingRulesFile()
+ \snippet logger/main.cpp 2
+
+ \row \li 2. \li The application developer can set the rules directly using \l qSetLoggingRules().
+ \snippet logger/main.cpp 5
+
+ \row \li 3. \li The logging rule file can be defined by using the environment variable called \section2 QT_LOGGING_CONFIG
+
+ The QT_LOGGING_CONFIG environment variable overrides both qSetLoggingRulesFile() and
+
+ qSetLoggingRules() if it points to a file.
+
+ If QT_LOGGING_CONFIG is relative, QStandardPaths::writeableLocation(QStandardPaths::ConfigLocation) will be prepended.
+ \endtable
+
+ If there is no loggin rules available, the \l {Default settings} will be used.
+
+ 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
@@ -151,16 +179,13 @@
\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.
+ In this example the configuration file "logrules.txt" is in the current directory.
For category-based logging statements, you need to use the \l qCDebug(), \l qCWarning() and \l qCCritical() macros.
\snippet logger/main.cpp 3
+
\section1 Default settings
The defaults are as follows.
@@ -177,5 +202,7 @@
In other words, only \l qCDebug() statements are hidden by default.
- \sa QLogging
+ \section1 Classes
+
+ \annotatedlist qlogging_classes
*/