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
7QT_BEGIN_NAMESPACE
8
9namespace QQmlJS {
10
11LoggerCategory::LoggerCategory() : d_ptr{ new LoggerCategoryPrivate } { }
12
13LoggerCategory::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
26LoggerCategory::LoggerCategory(const LoggerCategory &other)
27 : d_ptr{ new LoggerCategoryPrivate{ *other.d_func() } }
28{
29}
30
31LoggerCategory::LoggerCategory(LoggerCategory &&) noexcept = default;
32
33LoggerCategory &LoggerCategory::operator=(const LoggerCategory &other)
34{
35 *d_func() = *other.d_func();
36 return *this;
37}
38
39LoggerCategory &LoggerCategory::operator=(LoggerCategory &&) noexcept = default;
40
41LoggerCategory::~LoggerCategory() = default;
42
43QString LoggerCategory::name() const
44{
45 Q_D(const LoggerCategory);
46 return d->m_name;
47}
48
49QString LoggerCategory::settingsName() const
50{
51 Q_D(const LoggerCategory);
52 return d->m_settingsName;
53}
54
55QString LoggerCategory::description() const
56{
57 Q_D(const LoggerCategory);
58 return d->m_description;
59}
60
61QtMsgType LoggerCategory::level() const
62{
63 Q_D(const LoggerCategory);
64 return d->m_level;
65}
66
67bool LoggerCategory::isIgnored() const
68{
69 Q_D(const LoggerCategory);
70 return d->m_ignored;
71}
72
73bool LoggerCategory::isDefault() const
74{
75 Q_D(const LoggerCategory);
76 return d->m_isDefault;
77}
78
79LoggerWarningId LoggerCategory::id() const
80{
81 Q_D(const LoggerCategory);
82 return d->id();
83}
84
85void LoggerCategory::setLevel(QtMsgType type)
86{
87 Q_D(LoggerCategory);
88 d->setLevel(type);
89}
90
91void LoggerCategoryPrivate::setLevel(QtMsgType type)
92{
93 if (m_level == type)
94 return;
95
96 m_level = type;
97 m_changed = true;
98}
99
100void LoggerCategory::setIgnored(bool isIgnored)
101{
102 Q_D(LoggerCategory);
103 d->setIgnored(isIgnored);
104}
105
106void LoggerCategoryPrivate::setIgnored(bool isIgnored)
107{
108 if (m_ignored == isIgnored)
109 return;
110
111 m_ignored = isIgnored;
112 m_changed = true;
113}
114
115bool LoggerCategoryPrivate::hasChanged() const
116{
117 return m_changed;
118}
119
120LoggerCategoryPrivate *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
136QT_END_NAMESPACE
137

source code of qtdeclarative/src/qmlcompiler/qqmljsloggingutils.cpp