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