qloggingcategory.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qloggingcategory.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qloggingcategory.h"-
41#include "qloggingregistry_p.h"-
42-
43QT_BEGIN_NAMESPACE-
44-
45const char qtDefaultCategoryName[] = "default";-
46-
47Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory,
executed 433 times by 161 tests: end of block
Executed by:
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qaccessibility - unknown status
  • tst_qanimationgroup - unknown status
  • tst_qapplication - unknown status
  • tst_qarraydata - unknown status
  • tst_qarraydata_strictiterators - unknown status
  • tst_qboxlayout - unknown status
  • tst_qbrush - unknown status
  • tst_qbuffer - unknown status
  • tst_qbytearray - unknown status
  • tst_qcolor - unknown status
  • tst_qcolumnview - unknown status
  • tst_qcombobox - unknown status
  • tst_qcommandlineparser - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatastream - unknown status
  • tst_qdate - unknown status
  • tst_qdatetime - unknown status
  • ...
executed 433 times by 161 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qaccessibility - unknown status
  • tst_qanimationgroup - unknown status
  • tst_qapplication - unknown status
  • tst_qarraydata - unknown status
  • tst_qarraydata_strictiterators - unknown status
  • tst_qboxlayout - unknown status
  • tst_qbrush - unknown status
  • tst_qbuffer - unknown status
  • tst_qbytearray - unknown status
  • tst_qcolor - unknown status
  • tst_qcolumnview - unknown status
  • tst_qcombobox - unknown status
  • tst_qcommandlineparser - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatastream - unknown status
  • tst_qdate - unknown status
  • tst_qdatetime - unknown status
  • ...
executed 255515 times by 159 tests: return &holder.value;
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QByteArray
  • tst_QColor
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCompleter
  • tst_QDBusInterface
  • tst_QDBusLocalCalls
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • ...
guard.load() =...c::InitializedDescription
TRUEevaluated 433 times by 161 tests
Evaluated by:
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qaccessibility - unknown status
  • tst_qanimationgroup - unknown status
  • tst_qapplication - unknown status
  • tst_qarraydata - unknown status
  • tst_qarraydata_strictiterators - unknown status
  • tst_qboxlayout - unknown status
  • tst_qbrush - unknown status
  • tst_qbuffer - unknown status
  • tst_qbytearray - unknown status
  • tst_qcolor - unknown status
  • tst_qcolumnview - unknown status
  • tst_qcombobox - unknown status
  • tst_qcommandlineparser - unknown status
  • tst_qcompleter - unknown status
  • tst_qdatastream - unknown status
  • tst_qdate - unknown status
  • tst_qdatetime - unknown status
  • ...
FALSEnever evaluated
0-255515
48 (qtDefaultCategoryName))-
49-
50#ifndef Q_ATOMIC_INT8_IS_SUPPORTED-
51static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)-
52{-
53 const int bit = 1 << shift;-
54-
55 if (enable)-
56 atomic->fetchAndOrRelaxed(bit);-
57 else-
58 atomic->fetchAndAndRelaxed(~bit);-
59}-
60#endif-
61-
62/*!-
63 \class QLoggingCategory-
64 \inmodule QtCore-
65 \since 5.2-
66-
67 \brief The QLoggingCategory class represents a category, or 'area' in the-
68 logging infrastructure.-
69-
70 QLoggingCategory represents a certain logging category - identified by a-
71 string - at runtime. A category can be configured to enable or disable-
72 logging of messages per message type. Whether a message type is enabled or-
73 not can be checked with the \l isDebugEnabled(), \l isInfoEnabled(),-
74 \l isWarningEnabled(), and \l isCriticalEnabled() methods.-
75-
76 All objects are meant to be configured by a common registry (see also-
77 \l{Configuring Categories}). Different objects can also represent the same-
78 category. It is therefore not recommended to export objects across module-
79 boundaries, nor to manipulate the objects directly, nor to inherit from-
80 QLoggingCategory.-
81-
82 \section1 Creating Category Objects-
83-
84 The Q_DECLARE_LOGGING_CATEGORY() and Q_LOGGING_CATEGORY() macros-
85 conveniently declare and create QLoggingCategory objects:-
86-
87 \snippet qloggingcategory/main.cpp 1-
88-
89 \note Category names are free text. However, to allow easy configuration-
90 of the categories using \l{Logging Rules} the names should follow some rules:-
91 \list-
92 \li Use letters and numbers only.-
93 \li Further structure categories into common areas by using dots.-
94 \li Avoid the category names \c{debug}, \c{info}, \c{warning}, and \c{critical}.-
95 \li Category names starting with \c{qt} are reserved for Qt modules.-
96 \endlist-
97-
98 \section1 Checking Category Configuration-
99-
100 QLoggingCategory provides \l isDebugEnabled(), \l isInfoEnabled(),-
101 \l isWarningEnabled(), \l isCriticalEnabled(), as well as \l isEnabled()-
102 to check whether messages for the given message type should be logged.-
103-
104 \note The qCDebug(), qCWarning(), qCCritical() macros prevent arguments-
105 from being evaluated if the respective message types are not enabled for the-
106 category, so explicit checking is not needed:-
107-
108 \snippet qloggingcategory/main.cpp 4-
109-
110 \section1 Default Category Configuration-
111-
112 Both the QLoggingCategory constructor and the Q_LOGGING_CATEGORY() macro-
113 accept an optional QtMsgType argument, which disables all message types with-
114 a lower severity. That is, a category declared with-
115-
116 \snippet qloggingcategory/main.cpp 5-
117-
118 will log messages of type \c QtWarningMsg, \c QtCriticalMsg, \c QtFatalMsg, but will-
119 ignore messages of type \c QtDebugMsg and \c QtInfoMsg.-
120-
121 If no argument is passed, all messages will be logged.-
122-
123 \section1 Configuring Categories-
124-
125 The default configuration of categories can be overridden either by setting logging-
126 rules, or by installing a custom filter.-
127-
128 \section2 Logging Rules-
129-
130 Logging rules allow logging for categories to be enabled or disabled in a-
131 flexible way. Rules are specified in text, where every line must have the-
132 format-
133-
134 \code-
135 <category>[.<type>] = true|false-
136 \endcode-
137-
138 \c <category> is the name of the category, potentially with \c{*} as a-
139 wildcard symbol as the first or last character (or at both positions).-
140 The optional \c <type> must be either \c debug, \c info, \c warning, or \c critical.-
141 Lines that do not fit this scheme are ignored.-
142-
143 Rules are evaluated in text order, from first to last. That is, if two rules-
144 apply to a category/type, the rule that comes later is applied.-
145-
146 Rules can be set via \l setFilterRules(). Since Qt 5.3, logging rules can also-
147 be set in the \c QT_LOGGING_RULES environment variable, and-
148 are automatically loaded from the \c [Rules] section of a logging-
149 configuration file. Such configuration files are looked up in the QtProject-
150 configuration directory, or explicitly set in a \c QT_LOGGING_CONF-
151 environment variable:-
152-
153 \code-
154 [Rules]-
155 *.debug=false-
156 driver.usb.debug=true-
157 \endcode-
158-
159 Rules set by \l setFilterRules() take precedence over rules specified-
160 in the QtProject configuration directory, and can, in turn, be-
161 overwritten by rules from the configuration file specified by-
162 \c QT_LOGGING_CONF, and rules set by \c QT_LOGGING_RULES.-
163-
164-
165 Since Qt 5.6, \c QT_LOGGING_RULES may contain multiple rules separated-
166 by semicolons:-
167-
168 \code-
169 QT_LOGGING_RULES="*.debug=false;driver.usb.debug=true"-
170 \endcode-
171-
172-
173 Order of evaluation:-
174 \list-
175 \li [QLibraryInfo::DataPath]/qtlogging.ini-
176 \li QtProject/qtlogging.ini-
177 \li \l setFilterRules()-
178 \li \c QT_LOGGING_CONF-
179 \li \c QT_LOGGING_RULES-
180 \endlist-
181-
182 The \c QtProject/qtlogging.ini file is looked up in all directories returned-
183 by QStandardPaths::GenericConfigLocation, e.g.-
184-
185 \list-
186 \li on \macos and iOS: \c ~/Library/Preferences-
187 \li on Unix: \c ~/.config, \c /etc/xdg-
188 \li on Windows: \c %LOCALAPPDATA%, \c %ProgramData%,-
189 \l QCoreApplication::applicationDirPath(),-
190 QCoreApplication::applicationDirPath() + \c "/data"-
191 \endlist-
192-
193 Set the \c QT_LOGGING_DEBUG environment variable to see from where-
194 logging rules are loaded.-
195-
196 \section2 Installing a Custom Filter-
197-
198 As a lower-level alternative to the text rules, you can also implement a-
199 custom filter via \l installFilter(). All filter rules are ignored in this-
200 case.-
201-
202 \section1 Printing the Category-
203-
204 Use the \c %{category} placeholder to print the category in the default-
205 message handler:-
206-
207 \snippet qloggingcategory/main.cpp 3-
208*/-
209-
210/*!-
211 Constructs a QLoggingCategory object with the provided \a category name.-
212 All message types for this category are enabled by default.-
213-
214 If \a category is \c{0}, the category name is changed to \c "default".-
215*/-
216QLoggingCategory::QLoggingCategory(const char *category)-
217 : d(0),-
218 name(0)-
219{-
220 init(category, QtDebugMsg);-
221}
executed 914 times by 243 tests: end of block
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
914
222-
223/*!-
224 Constructs a QLoggingCategory object with the provided \a category name,-
225 and enables all messages with types more severe or equal than \a enableForLevel.-
226-
227 If \a category is \c{0}, the category name is changed to \c "default".-
228-
229 \since 5.4-
230*/-
231QLoggingCategory::QLoggingCategory(const char *category, QtMsgType enableForLevel)-
232 : d(0),-
233 name(0)-
234{-
235 init(category, enableForLevel);-
236}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QLogging
4
237-
238void QLoggingCategory::init(const char *category, QtMsgType severityLevel)-
239{-
240 enabled.store(0x01010101); // enabledDebug = enabledWarning = enabledCritical = true;-
241-
242 if (category)
categoryDescription
TRUEevaluated 916 times by 243 tests
Evaluated by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QLogging
2-916
243 name = category;
executed 916 times by 243 tests: name = category;
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
916
244 else-
245 name = qtDefaultCategoryName;
executed 2 times by 1 test: name = qtDefaultCategoryName;
Executed by:
  • tst_QLogging
2
246-
247 if (QLoggingRegistry *reg = QLoggingRegistry::instance())
QLoggingRegist...ry::instance()Description
TRUEevaluated 918 times by 243 tests
Evaluated by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
FALSEnever evaluated
0-918
248 reg->registerCategory(this, severityLevel);
executed 918 times by 243 tests: reg->registerCategory(this, severityLevel);
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
918
249}
executed 918 times by 243 tests: end of block
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
918
250-
251/*!-
252 Destructs a QLoggingCategory object.-
253*/-
254QLoggingCategory::~QLoggingCategory()-
255{-
256 if (QLoggingRegistry *reg = QLoggingRegistry::instance())
QLoggingRegist...ry::instance()Description
TRUEevaluated 1485 times by 306 tests
Evaluated by:
  • tst_QLogging
  • tst_QLoggingRegistry
  • tst_QNoDebug
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • tst_qactiongroup - unknown status
  • tst_qanimationgroup - unknown status
  • tst_qapplication - unknown status
  • ...
FALSEnever evaluated
0-1485
257 reg->unregisterCategory(this);
executed 1485 times by 306 tests: reg->unregisterCategory(this);
Executed by:
  • tst_QLogging
  • tst_QLoggingRegistry
  • tst_QNoDebug
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • tst_qactiongroup - unknown status
  • tst_qanimationgroup - unknown status
  • tst_qapplication - unknown status
  • ...
1485
258}
executed 1485 times by 306 tests: end of block
Executed by:
  • tst_QLogging
  • tst_QLoggingRegistry
  • tst_QNoDebug
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • tst_qactiongroup - unknown status
  • tst_qanimationgroup - unknown status
  • tst_qapplication - unknown status
  • ...
1485
259-
260/*!-
261 \fn const char *QLoggingCategory::categoryName() const-
262-
263 Returns the name of the category.-
264*/-
265-
266/*!-
267 \fn bool QLoggingCategory::isDebugEnabled() const-
268-
269 Returns \c true if debug messages should be shown for this category.-
270 Returns \c false otherwise.-
271-
272 \note The \l qCDebug() macro already does this check before executing any-
273 code. However, calling this method may be useful to avoid-
274 expensive generation of data that is only used for debug output.-
275*/-
276-
277-
278/*!-
279 \fn bool QLoggingCategory::isInfoEnabled() const-
280-
281 Returns \c true if informational messages should be shown for this category.-
282 Returns \c false otherwise.-
283-
284 \note The \l qCInfo() macro already does this check before executing any-
285 code. However, calling this method may be useful to avoid-
286 expensive generation of data that is only used for debug output.-
287-
288 \since 5.5-
289*/-
290-
291-
292/*!-
293 \fn bool QLoggingCategory::isWarningEnabled() const-
294-
295 Returns \c true if warning messages should be shown for this category.-
296 Returns \c false otherwise.-
297-
298 \note The \l qCWarning() macro already does this check before executing any-
299 code. However, calling this method may be useful to avoid-
300 expensive generation of data that is only used for debug output.-
301*/-
302-
303/*!-
304 \fn bool QLoggingCategory::isCriticalEnabled() const-
305-
306 Returns \c true if critical messages should be shown for this category.-
307 Returns \c false otherwise.-
308-
309 \note The \l qCCritical() macro already does this check before executing any-
310 code. However, calling this method may be useful to avoid-
311 expensive generation of data that is only used for debug output.-
312*/-
313-
314/*!-
315 Returns \c true if a message of type \a msgtype for the category should be-
316 shown. Returns \c false otherwise.-
317*/-
318bool QLoggingCategory::isEnabled(QtMsgType msgtype) const-
319{-
320 switch (msgtype) {-
321 case QtDebugMsg: return isDebugEnabled();
executed 3781 times by 72 tests: return isDebugEnabled();
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBrush
  • tst_QColumnView
  • tst_QDBusInterface
  • tst_QDate
  • tst_QDateTime
  • tst_QDebug
  • tst_QElapsedTimer
  • tst_QEventLoop
  • tst_QFileSystemWatcher
  • tst_QFtp
  • tst_QGraphicsScene
  • tst_QGuiEventLoop
  • tst_QGuiVariant
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLocalSocket
  • ...
executed 3781 times by 72 tests: case QtDebugMsg:
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBrush
  • tst_QColumnView
  • tst_QDBusInterface
  • tst_QDate
  • tst_QDateTime
  • tst_QDebug
  • tst_QElapsedTimer
  • tst_QEventLoop
  • tst_QFileSystemWatcher
  • tst_QFtp
  • tst_QGraphicsScene
  • tst_QGuiEventLoop
  • tst_QGuiVariant
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QLocalSocket
  • ...
3781
322 case QtInfoMsg: return isInfoEnabled();
executed 102 times by 3 tests: return isInfoEnabled();
Executed by:
  • tst_QLogging
  • tst_qlogging - unknown status
  • tst_selftests - unknown status
executed 102 times by 3 tests: case QtInfoMsg:
Executed by:
  • tst_QLogging
  • tst_qlogging - unknown status
  • tst_selftests - unknown status
102
323 case QtWarningMsg: return isWarningEnabled();
executed 251550 times by 127 tests: return isWarningEnabled();
Executed by:
  • tst_Gestures
  • tst_LargeFile
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QByteArray
  • tst_QColor
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCompleter
  • tst_QDBusInterface
  • tst_QDBusLocalCalls
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDesktopWidget
  • tst_QDialogButtonBox
  • tst_QDir
  • ...
executed 251550 times by 127 tests: case QtWarningMsg:
Executed by:
  • tst_Gestures
  • tst_LargeFile
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QByteArray
  • tst_QColor
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCompleter
  • tst_QDBusInterface
  • tst_QDBusLocalCalls
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDebug
  • tst_QDesktopWidget
  • tst_QDialogButtonBox
  • tst_QDir
  • ...
251550
324 case QtCriticalMsg: return isCriticalEnabled();
executed 34 times by 4 tests: return isCriticalEnabled();
Executed by:
  • tst_QDebug
  • tst_QLogging
  • tst_qlogging - unknown status
  • tst_selftests - unknown status
executed 34 times by 4 tests: case QtCriticalMsg:
Executed by:
  • tst_QDebug
  • tst_QLogging
  • tst_qlogging - unknown status
  • tst_selftests - unknown status
34
325 case QtFatalMsg: return true;
executed 55 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_selftests - unknown status
executed 55 times by 2 tests: case QtFatalMsg:
Executed by:
  • tst_QNetworkReply
  • tst_selftests - unknown status
55
326 }-
327 return false;
never executed: return false;
0
328}-
329-
330/*!-
331 Changes the message type \a type for the category to \a enable.-
332-
333 \note Changes only affect the current QLoggingCategory object, and won't-
334 change the settings of other objects for the same category name.-
335 Use either \l setFilterRules() or \l installFilter() to change the-
336 configuration globally.-
337-
338 \note \c QtFatalMsg cannot be changed. It will always return \c true.-
339*/-
340void QLoggingCategory::setEnabled(QtMsgType type, bool enable)-
341{-
342 switch (type) {-
343#ifdef Q_ATOMIC_INT8_IS_SUPPORTED-
344 case QtDebugMsg: bools.enabledDebug.store(enable); break;
executed 217078 times by 243 tests: break;
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
executed 217078 times by 243 tests: case QtDebugMsg:
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
217078
345 case QtInfoMsg: bools.enabledInfo.store(enable); break;
executed 217065 times by 243 tests: break;
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
executed 217065 times by 243 tests: case QtInfoMsg:
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
217065
346 case QtWarningMsg: bools.enabledWarning.store(enable); break;
executed 217065 times by 243 tests: break;
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
executed 217065 times by 243 tests: case QtWarningMsg:
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
217065
347 case QtCriticalMsg: bools.enabledCritical.store(enable); break;
executed 217065 times by 243 tests: break;
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
executed 217065 times by 243 tests: case QtCriticalMsg:
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
217065
348#else-
349 case QtDebugMsg: setBoolLane(&enabled, enable, DebugShift); break;-
350 case QtInfoMsg: setBoolLane(&enabled, enable, InfoShift); break;-
351 case QtWarningMsg: setBoolLane(&enabled, enable, WarningShift); break;-
352 case QtCriticalMsg: setBoolLane(&enabled, enable, CriticalShift); break;-
353#endif-
354 case QtFatalMsg: break;
never executed: break;
never executed: case QtFatalMsg:
0
355 }-
356}
executed 868273 times by 243 tests: end of block
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QByteArray
  • tst_QCalendarWidget
  • ...
868273
357-
358/*!-
359 \fn QLoggingCategory &QLoggingCategory::operator()()-
360-
361 Returns the object itself. This allows both a QLoggingCategory variable, and-
362 a factory method returning a QLoggingCategory, to be used in \l qCDebug(),-
363 \l qCWarning(), \l qCCritical() macros.-
364 */-
365-
366/*!-
367 \fn const QLoggingCategory &QLoggingCategory::operator()() const-
368-
369 Returns the object itself. This allows both a QLoggingCategory variable, and-
370 a factory method returning a QLoggingCategory, to be used in \l qCDebug(),-
371 \l qCWarning(), \l qCCritical() macros.-
372 */-
373-
374/*!-
375 Returns a pointer to the global category \c "default" that-
376 is used e.g. by qDebug(), qInfo(), qWarning(), qCritical(), qFatal().-
377-
378 \note The returned pointer may be null during destruction of-
379 static objects.-
380-
381 \note Ownership of the category is not transferred, do not-
382 \c delete the returned pointer.-
383-
384 */-
385QLoggingCategory *QLoggingCategory::defaultCategory()-
386{-
387 return qtDefaultCategory();
executed 255515 times by 159 tests: return qtDefaultCategory();
Executed by:
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractItemView
  • tst_QAccessibility
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QByteArray
  • tst_QColor
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCompleter
  • tst_QDBusInterface
  • tst_QDBusLocalCalls
  • tst_QDBusMarshall
  • tst_QDBusMetaType
  • ...
255515
388}-
389-
390/*!-
391 \typedef QLoggingCategory::CategoryFilter-
392-
393 This is a typedef for a pointer to a function with the following-
394 signature:-
395-
396 \snippet qloggingcategory/main.cpp 20-
397-
398 A function with this signature can be installed with \l installFilter().-
399*/-
400-
401/*!-
402 Installs a function \a filter that is used to determine which categories-
403 and message types should be enabled. Returns a pointer to the previous-
404 installed filter.-
405-
406 Every QLoggingCategory object created is passed to the filter, and the-
407 filter is free to change the respective category configuration with-
408 \l setEnabled().-
409-
410 The filter might be called concurrently from different threads, and-
411 therefore has to be reentrant.-
412-
413 Example:-
414 \snippet qloggingcategory/main.cpp 21-
415-
416 An alternative way of configuring the default filter is via-
417 \l setFilterRules().-
418 */-
419QLoggingCategory::CategoryFilter-
420QLoggingCategory::installFilter(QLoggingCategory::CategoryFilter filter)-
421{-
422 return QLoggingRegistry::instance()->installFilter(filter);
executed 7 times by 1 test: return QLoggingRegistry::instance()->installFilter(filter);
Executed by:
  • tst_QLogging
7
423}-
424-
425/*!-
426 Configures which categories and message types should be enabled through a-
427 a set of \a rules.-
428-
429 Example:-
430-
431 \snippet qloggingcategory/main.cpp 2-
432-
433 \note The rules might be ignored if a custom category filter is installed-
434 with \l installFilter(), or if the user defined \c QT_LOGGING_CONF or \c QT_LOGGING_RULES-
435 environment variable.-
436*/-
437void QLoggingCategory::setFilterRules(const QString &rules)-
438{-
439 QLoggingRegistry::instance()->setApiRules(rules);-
440}
executed 24019 times by 2 tests: end of block
Executed by:
  • tst_QLogging
  • tst_QLoggingRegistry
24019
441-
442/*!-
443 \macro qCDebug(category)-
444 \relates QLoggingCategory-
445 \since 5.2-
446-
447 Returns an output stream for debug messages in the logging category-
448 \a category.-
449-
450 The macro expands to code that checks whether-
451 \l QLoggingCategory::isDebugEnabled() evaluates to \c true.-
452 If so, the stream arguments are processed and sent to the message handler.-
453-
454 Example:-
455-
456 \snippet qloggingcategory/main.cpp 10-
457-
458 \note Arguments are not processed if debug output for the category is not-
459 enabled, so do not rely on any side effects.-
460-
461 \sa qDebug()-
462*/-
463-
464/*!-
465 \macro qCDebug(category, const char *message, ...)-
466 \relates QLoggingCategory-
467 \since 5.3-
468-
469 Logs a debug message \a message in the logging category \a category.-
470 \a message might contain place holders that are replaced by additional-
471 arguments, similar to the C printf() function.-
472-
473 Example:-
474-
475 \snippet qloggingcategory/main.cpp 13-
476-
477 \note Arguments might not be processed if debug output for the category is-
478 not enabled, so do not rely on any side effects.-
479-
480 \sa qDebug()-
481*/-
482-
483/*!-
484 \macro qCInfo(category)-
485 \relates QLoggingCategory-
486 \since 5.5-
487-
488 Returns an output stream for informational messages in the logging category-
489 \a category.-
490-
491 The macro expands to code that checks whether-
492 \l QLoggingCategory::isInfoEnabled() evaluates to \c true.-
493 If so, the stream arguments are processed and sent to the message handler.-
494-
495 Example:-
496-
497 \snippet qloggingcategory/main.cpp qcinfo_stream-
498-
499 \note Arguments are not processed if debug output for the category is not-
500 enabled, so do not rely on any side effects.-
501-
502 \sa qInfo()-
503*/-
504-
505/*!-
506 \macro qCInfo(category, const char *message, ...)-
507 \relates QLoggingCategory-
508 \since 5.5-
509-
510 Logs an informational message \a message in the logging category \a category.-
511 \a message might contain place holders that are replaced by additional-
512 arguments, similar to the C printf() function.-
513-
514 Example:-
515-
516 \snippet qloggingcategory/main.cpp qcinfo_printf-
517-
518 \note Arguments might not be processed if debug output for the category is-
519 not enabled, so do not rely on any side effects.-
520-
521 \sa qInfo()-
522*/-
523-
524/*!-
525 \macro qCWarning(category)-
526 \relates QLoggingCategory-
527 \since 5.2-
528-
529 Returns an output stream for warning messages in the logging category-
530 \a category.-
531-
532 The macro expands to code that checks whether-
533 \l QLoggingCategory::isWarningEnabled() evaluates to \c true.-
534 If so, the stream arguments are processed and sent to the message handler.-
535-
536 Example:-
537-
538 \snippet qloggingcategory/main.cpp 11-
539-
540 \note Arguments are not processed if warning output for the category is not-
541 enabled, so do not rely on any side effects.-
542-
543 \sa qWarning()-
544*/-
545-
546/*!-
547 \macro qCWarning(category, const char *message, ...)-
548 \relates QLoggingCategory-
549 \since 5.3-
550-
551 Logs a warning message \a message in the logging category \a category.-
552 \a message might contain place holders that are replaced by additional-
553 arguments, similar to the C printf() function.-
554-
555 Example:-
556-
557 \snippet qloggingcategory/main.cpp 14-
558-
559 \note Arguments might not be processed if warning output for the category is-
560 not enabled, so do not rely on any side effects.-
561-
562 \sa qWarning()-
563*/-
564-
565/*!-
566 \macro qCCritical(category)-
567 \relates QLoggingCategory-
568 \since 5.2-
569-
570 Returns an output stream for critical messages in the logging category-
571 \a category.-
572-
573 The macro expands to code that checks whether-
574 \l QLoggingCategory::isCriticalEnabled() evaluates to \c true.-
575 If so, the stream arguments are processed and sent to the message handler.-
576-
577 Example:-
578-
579 \snippet qloggingcategory/main.cpp 12-
580-
581 \note Arguments are not processed if critical output for the category is not-
582 enabled, so do not rely on any side effects.-
583-
584 \sa qCritical()-
585*/-
586-
587/*!-
588 \macro qCCritical(category, const char *message, ...)-
589 \relates QLoggingCategory-
590 \since 5.3-
591-
592 Logs a critical message \a message in the logging category \a category.-
593 \a message might contain place holders that are replaced by additional-
594 arguments, similar to the C printf() function.-
595-
596 Example:-
597-
598 \snippet qloggingcategory/main.cpp 15-
599-
600 \note Arguments might not be processed if critical output for the category-
601 is not enabled, so do not rely on any side effects.-
602-
603 \sa qCritical()-
604*/-
605/*!-
606 \macro Q_DECLARE_LOGGING_CATEGORY(name)-
607 \sa Q_LOGGING_CATEGORY()-
608 \relates QLoggingCategory-
609 \since 5.2-
610-
611 Declares a logging category \a name. The macro can be used to declare-
612 a common logging category shared in different parts of the program.-
613-
614 This macro must be used outside of a class or method.-
615*/-
616-
617/*!-
618 \macro Q_LOGGING_CATEGORY(name, string)-
619 \sa Q_DECLARE_LOGGING_CATEGORY()-
620 \relates QLoggingCategory-
621 \since 5.2-
622-
623 Defines a logging category \a name, and makes it configurable under the-
624 \a string identifier. By default, all message types are enabled.-
625-
626 Only one translation unit in a library or executable can define a category-
627 with a specific name.-
628-
629 This macro must be used outside of a class or method.-
630*/-
631-
632/*!-
633 \macro Q_LOGGING_CATEGORY(name, string, msgType)-
634 \sa Q_DECLARE_LOGGING_CATEGORY()-
635 \relates QLoggingCategory-
636 \since 5.4-
637-
638 Defines a logging category \a name, and makes it configurable under the-
639 \a string identifier. By default, messages of QtMsgType \a msgType-
640 and more severe are enabled, types with a lower severity are disabled.-
641-
642 Only one translation unit in a library or executable can define a category-
643 with a specific name.-
644-
645 This macro must be used outside of a class or method. It is only defined-
646 if variadic macros are supported.-
647*/-
648-
649QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9