1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QQMLJSLOGGINGUTILS_P_H
5#define QQMLJSLOGGINGUTILS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qstring.h>
19#include <qtqmlcompilerexports.h>
20
21#include "qqmljsloggingutils.h"
22
23QT_BEGIN_NAMESPACE
24
25class QQmlToolingSettings;
26class QCommandLineParser;
27
28namespace QQmlJS {
29
30using LoggerWarningId = QQmlSA::LoggerWarningId;
31
32class LoggerCategoryPrivate;
33
34class Q_QMLCOMPILER_EXPORT LoggerCategory
35{
36 Q_DECLARE_PRIVATE(LoggerCategory)
37
38public:
39 LoggerCategory();
40 LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level,
41 bool ignored = false, bool isDefault = false);
42 LoggerCategory(const LoggerCategory &);
43 LoggerCategory(LoggerCategory &&) noexcept;
44 LoggerCategory &operator=(const LoggerCategory &);
45 LoggerCategory &operator=(LoggerCategory &&) noexcept;
46 ~LoggerCategory();
47
48 QString name() const;
49 QString settingsName() const;
50 QString description() const;
51 QtMsgType level() const;
52 bool isIgnored() const;
53 bool isDefault() const;
54
55 LoggerWarningId id() const;
56
57 void setLevel(QtMsgType);
58 void setIgnored(bool);
59
60private:
61 std::unique_ptr<QQmlJS::LoggerCategoryPrivate> d_ptr;
62};
63
64class LoggerCategoryPrivate
65{
66 friend class QT_PREPEND_NAMESPACE(QQmlJS::LoggerCategory);
67
68public:
69 LoggerWarningId id() const { return LoggerWarningId(m_name); }
70
71 void setLevel(QtMsgType);
72 void setIgnored(bool);
73
74 QString name() const;
75 QString settingsName() const;
76 QString description() const;
77 QtMsgType level() const;
78 bool isIgnored() const;
79 bool isDefault() const;
80 bool hasChanged() const;
81
82 static LoggerCategoryPrivate *get(LoggerCategory *);
83
84 friend bool operator==(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
85 {
86 return operatorEqualsImpl(lhs, rhs);
87 }
88 friend bool operator!=(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
89 {
90 return !operatorEqualsImpl(lhs, rhs);
91 }
92
93 bool operator==(const LoggerWarningId warningId) const { return warningId.name() == m_name; }
94
95private:
96 static bool operatorEqualsImpl(const LoggerCategoryPrivate &, const LoggerCategoryPrivate &);
97
98 QString m_name;
99 QString m_settingsName;
100 QString m_description;
101 QtMsgType m_level = QtDebugMsg;
102 bool m_ignored = false;
103 bool m_isDefault = false; // Whether or not the category can be disabled
104 bool m_changed = false;
105};
106
107namespace LoggingUtils {
108Q_QMLCOMPILER_EXPORT void updateLogLevels(QList<LoggerCategory> &categories,
109 const QQmlToolingSettings &settings,
110 QCommandLineParser *parser);
111
112Q_QMLCOMPILER_EXPORT QString levelToString(const QQmlJS::LoggerCategory &category);
113} // namespace LoggingUtils
114
115} // namespace QQmlJS
116
117QT_END_NAMESPACE
118
119#endif // QQMLJSLOGGINGUTILS_P_H
120

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtdeclarative/src/qmlcompiler/qqmljsloggingutils_p.h