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 | #include "qqmljsloggingutils.h" |
5 | #include "qqmljsloggingutils_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace QQmlJS { |
10 | |
11 | LoggerCategory::LoggerCategory() : d_ptr{ new LoggerCategoryPrivate } { } |
12 | |
13 | LoggerCategory::LoggerCategory(QString name, QString settingsName, QString description, |
14 | QtMsgType level, bool ignored, bool isDefault) |
15 | : d_ptr{ new LoggerCategoryPrivate } |
16 | { |
17 | Q_D(LoggerCategory); |
18 | d->m_name = name; |
19 | d->m_settingsName = settingsName; |
20 | d->m_description = description; |
21 | d->m_level = level; |
22 | d->m_ignored = ignored; |
23 | d->m_isDefault = isDefault; |
24 | } |
25 | |
26 | LoggerCategory::LoggerCategory(const LoggerCategory &other) |
27 | : d_ptr{ new LoggerCategoryPrivate{ *other.d_func() } } |
28 | { |
29 | } |
30 | |
31 | LoggerCategory::LoggerCategory(LoggerCategory &&) noexcept = default; |
32 | |
33 | LoggerCategory &LoggerCategory::operator=(const LoggerCategory &other) |
34 | { |
35 | *d_func() = *other.d_func(); |
36 | return *this; |
37 | } |
38 | |
39 | LoggerCategory &LoggerCategory::operator=(LoggerCategory &&) noexcept = default; |
40 | |
41 | LoggerCategory::~LoggerCategory() = default; |
42 | |
43 | QString LoggerCategory::name() const |
44 | { |
45 | Q_D(const LoggerCategory); |
46 | return d->m_name; |
47 | } |
48 | |
49 | QString LoggerCategory::settingsName() const |
50 | { |
51 | Q_D(const LoggerCategory); |
52 | return d->m_settingsName; |
53 | } |
54 | |
55 | QString LoggerCategory::description() const |
56 | { |
57 | Q_D(const LoggerCategory); |
58 | return d->m_description; |
59 | } |
60 | |
61 | QtMsgType LoggerCategory::level() const |
62 | { |
63 | Q_D(const LoggerCategory); |
64 | return d->m_level; |
65 | } |
66 | |
67 | bool LoggerCategory::isIgnored() const |
68 | { |
69 | Q_D(const LoggerCategory); |
70 | return d->m_ignored; |
71 | } |
72 | |
73 | bool LoggerCategory::isDefault() const |
74 | { |
75 | Q_D(const LoggerCategory); |
76 | return d->m_isDefault; |
77 | } |
78 | |
79 | LoggerWarningId LoggerCategory::id() const |
80 | { |
81 | Q_D(const LoggerCategory); |
82 | return d->id(); |
83 | } |
84 | |
85 | void LoggerCategory::setLevel(QtMsgType type) |
86 | { |
87 | Q_D(LoggerCategory); |
88 | d->setLevel(type); |
89 | } |
90 | |
91 | void LoggerCategoryPrivate::setLevel(QtMsgType type) |
92 | { |
93 | if (m_level == type) |
94 | return; |
95 | |
96 | m_level = type; |
97 | m_changed = true; |
98 | } |
99 | |
100 | void LoggerCategory::setIgnored(bool isIgnored) |
101 | { |
102 | Q_D(LoggerCategory); |
103 | d->setIgnored(isIgnored); |
104 | } |
105 | |
106 | void LoggerCategoryPrivate::setIgnored(bool isIgnored) |
107 | { |
108 | if (m_ignored == isIgnored) |
109 | return; |
110 | |
111 | m_ignored = isIgnored; |
112 | m_changed = true; |
113 | } |
114 | |
115 | bool LoggerCategoryPrivate::hasChanged() const |
116 | { |
117 | return m_changed; |
118 | } |
119 | |
120 | LoggerCategoryPrivate *LoggerCategoryPrivate::get(LoggerCategory *loggerCategory) |
121 | { |
122 | Q_ASSERT(loggerCategory); |
123 | return loggerCategory->d_func(); |
124 | } |
125 | |
126 | /*! |
127 | \class QQmlSA::LoggerWarningId |
128 | \inmodule QtQmlCompiler |
129 | |
130 | \brief A wrapper around a string literal to uniquely identify |
131 | warning categories in the \c{QQmlSA} framework. |
132 | */ |
133 | |
134 | } // namespace QQmlJS |
135 | |
136 | QT_END_NAMESPACE |
137 |