Add server debug JSON RPC functionality
This commit is contained in:
parent
48658b45f1
commit
6500fce3fd
@ -146,6 +146,9 @@
|
||||
#include "zwave/zwavemanager.h"
|
||||
#include "zwave/zwavenetwork.h"
|
||||
#include "zwave/zwavenode.h"
|
||||
#include "serverdebug/serverdebugmanager.h"
|
||||
#include "serverdebug/serverloggingcategory.h"
|
||||
#include "serverdebug/serverloggingcategories.h"
|
||||
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
@ -360,6 +363,10 @@ void registerQmlTypes() {
|
||||
qmlRegisterUncreatableType<WiredNetworkDevice>(uri, 1, 0, "WiredNetworkDevice", "Get it from NetworkDevices");
|
||||
qmlRegisterUncreatableType<WirelessNetworkDevice>(uri, 1, 0, "WirelessNetworkDevice", "Get it from NetworkDevices");
|
||||
|
||||
qmlRegisterType<ServerDebugManager>(uri, 1, 0, "ServerDebugManager");
|
||||
qmlRegisterUncreatableType<ServerLoggingCategory>(uri, 1, 0, "ServerLoggingCategory", "Get it from ServerDebugManager");
|
||||
qmlRegisterUncreatableType<ServerLoggingCategories>(uri, 1, 0, "ServerLoggingCategories", "Get it from ServerDebugManager");
|
||||
|
||||
qmlRegisterUncreatableType<ScriptManager>(uri, 1, 0, "ScriptManager", "Get it from Engine");
|
||||
qmlRegisterUncreatableType<Scripts>(uri, 1, 0, "Scripts", "Getit from ScriptManager");
|
||||
qmlRegisterUncreatableType<Script>(uri, 1, 0, "Script", "Getit from Scripts");
|
||||
|
||||
@ -32,6 +32,9 @@ SOURCES += \
|
||||
$$PWD/models/newlogsmodel.cpp \
|
||||
$$PWD/models/scriptsproxymodel.cpp \
|
||||
$$PWD/pluginconfigmanager.cpp \
|
||||
$$PWD/serverdebug/serverdebugmanager.cpp \
|
||||
$$PWD/serverdebug/serverloggingcategories.cpp \
|
||||
$$PWD/serverdebug/serverloggingcategory.cpp \
|
||||
$$PWD/tagwatcher.cpp \
|
||||
$$PWD/zigbee/zigbeenode.cpp \
|
||||
$$PWD/zigbee/zigbeenodes.cpp \
|
||||
@ -198,6 +201,9 @@ HEADERS += \
|
||||
$$PWD/models/newlogsmodel.h \
|
||||
$$PWD/models/scriptsproxymodel.h \
|
||||
$$PWD/pluginconfigmanager.h \
|
||||
$$PWD/serverdebug/serverdebugmanager.h \
|
||||
$$PWD/serverdebug/serverloggingcategories.h \
|
||||
$$PWD/serverdebug/serverloggingcategory.h \
|
||||
$$PWD/tagwatcher.h \
|
||||
$$PWD/zigbee/zigbeenode.h \
|
||||
$$PWD/zigbee/zigbeenodes.h \
|
||||
|
||||
150
libnymea-app/serverdebug/serverdebugmanager.cpp
Normal file
150
libnymea-app/serverdebug/serverdebugmanager.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "serverdebugmanager.h"
|
||||
|
||||
#include "engine.h"
|
||||
#include "logging.h"
|
||||
#include "serverloggingcategories.h"
|
||||
|
||||
NYMEA_LOGGING_CATEGORY(dcServerDebug, "ServerDebug")
|
||||
|
||||
ServerDebugManager::ServerDebugManager(QObject *parent)
|
||||
: QObject{parent},
|
||||
m_categories{new ServerLoggingCategories(this)}
|
||||
{
|
||||
qRegisterMetaType<ServerLoggingCategory*>("ServerLoggingCategory");
|
||||
}
|
||||
|
||||
ServerDebugManager::~ServerDebugManager()
|
||||
{
|
||||
if (m_engine) {
|
||||
m_engine->jsonRpcClient()->unregisterNotificationHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
Engine *ServerDebugManager::engine() const
|
||||
{
|
||||
return m_engine;
|
||||
}
|
||||
|
||||
void ServerDebugManager::setEngine(Engine *engine)
|
||||
{
|
||||
if (m_engine != engine) {
|
||||
|
||||
if (m_engine)
|
||||
m_engine->jsonRpcClient()->unregisterNotificationHandler(this);
|
||||
|
||||
m_engine = engine;
|
||||
emit engineChanged();
|
||||
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
ServerLoggingCategories *ServerDebugManager::categories() const
|
||||
{
|
||||
return m_categories;
|
||||
}
|
||||
|
||||
bool ServerDebugManager::fetchingData() const
|
||||
{
|
||||
return m_fetchingData;
|
||||
}
|
||||
|
||||
void ServerDebugManager::getLoggingCategories()
|
||||
{
|
||||
if (!m_engine)
|
||||
return;
|
||||
|
||||
m_engine->jsonRpcClient()->sendCommand("Debug.GetLoggingCategories", this, "getLoggingCategoriesResponse");
|
||||
}
|
||||
|
||||
void ServerDebugManager::setLoggingLevel(const QString &name, int level)
|
||||
{
|
||||
if (!m_engine)
|
||||
return;
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("name", name);
|
||||
switch (level) {
|
||||
case ServerLoggingCategory::LevelCritical:
|
||||
params.insert("level", "LoggingLevelCritical");
|
||||
break;
|
||||
case ServerLoggingCategory::LevelWarning:
|
||||
params.insert("level", "LoggingLevelWarning");
|
||||
break;
|
||||
case ServerLoggingCategory::LevelInfo:
|
||||
params.insert("level", "LoggingLevelInfo");
|
||||
break;
|
||||
case ServerLoggingCategory::LevelDebug:
|
||||
params.insert("level", "LoggingLevelDebug");
|
||||
break;
|
||||
}
|
||||
|
||||
m_engine->jsonRpcClient()->sendCommand("Debug.SetLoggingCategoryLevel", params, this, "setLoggingCategoryLevelResponse");
|
||||
}
|
||||
|
||||
void ServerDebugManager::notificationReceived(const QVariantMap ¬ification)
|
||||
{
|
||||
qCDebug(dcServerDebug()) << "Notification received" << notification;
|
||||
}
|
||||
|
||||
void ServerDebugManager::init()
|
||||
{
|
||||
m_fetchingData = true;
|
||||
emit fetchingDataChanged();
|
||||
|
||||
if (m_engine)
|
||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "Debug", "notificationReceived");
|
||||
|
||||
getLoggingCategories();
|
||||
}
|
||||
|
||||
void ServerDebugManager::getLoggingCategoriesResponse(int commandId, const QVariantMap ¶ms)
|
||||
{
|
||||
Q_UNUSED(commandId)
|
||||
QVariantList categories = params.value("loggingCategories").toList();
|
||||
m_categories->createFromVariantList(categories);
|
||||
|
||||
// foreach (const QVariant &categoryVariant, categories) {
|
||||
// QVariantMap categoryMap = categoryVariant.toMap();
|
||||
// qCDebug(dcServerDebug()) << categoryMap.value("name").toString() << categoryMap.value("level").toString() << categoryMap.value("type").toString();
|
||||
// }
|
||||
|
||||
m_fetchingData = false;
|
||||
emit fetchingDataChanged();
|
||||
}
|
||||
|
||||
void ServerDebugManager::setLoggingCategoryLevelResponse(int commandId, const QVariantMap ¶ms)
|
||||
{
|
||||
Q_UNUSED(commandId)
|
||||
qCDebug(dcServerDebug()) << "Response for setting logging level" << params;
|
||||
}
|
||||
83
libnymea-app/serverdebug/serverdebugmanager.h
Normal file
83
libnymea-app/serverdebug/serverdebugmanager.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef SERVERDEBUGMANAGER_H
|
||||
#define SERVERDEBUGMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "serverloggingcategory.h"
|
||||
|
||||
class Engine;
|
||||
class JsonRpcClient;
|
||||
class ServerLoggingCategories;
|
||||
|
||||
class ServerDebugManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||
Q_PROPERTY(bool fetchingData READ fetchingData NOTIFY fetchingDataChanged)
|
||||
Q_PROPERTY(ServerLoggingCategories *categories READ categories CONSTANT FINAL)
|
||||
|
||||
public:
|
||||
explicit ServerDebugManager(QObject *parent = nullptr);
|
||||
~ServerDebugManager();
|
||||
|
||||
Engine *engine() const;
|
||||
void setEngine(Engine *engine);
|
||||
|
||||
ServerLoggingCategories *categories() const;
|
||||
|
||||
bool fetchingData() const;
|
||||
|
||||
Q_INVOKABLE void getLoggingCategories();
|
||||
Q_INVOKABLE void setLoggingLevel(const QString &name, int level);
|
||||
|
||||
signals:
|
||||
void engineChanged();
|
||||
void fetchingDataChanged();
|
||||
|
||||
private slots:
|
||||
void notificationReceived(const QVariantMap ¬ification);
|
||||
|
||||
private:
|
||||
Engine *m_engine = nullptr;
|
||||
ServerLoggingCategories *m_categories = nullptr;
|
||||
|
||||
bool m_fetchingData = false;
|
||||
|
||||
void init();
|
||||
|
||||
Q_INVOKABLE void getLoggingCategoriesResponse(int commandId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void setLoggingCategoryLevelResponse(int commandId, const QVariantMap ¶ms);
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVERDEBUGMANAGER_H
|
||||
86
libnymea-app/serverdebug/serverloggingcategories.cpp
Normal file
86
libnymea-app/serverdebug/serverloggingcategories.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "serverloggingcategories.h"
|
||||
|
||||
ServerLoggingCategories::ServerLoggingCategories(QObject *parent)
|
||||
: QAbstractListModel{parent}
|
||||
{}
|
||||
|
||||
int ServerLoggingCategories::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_list.count();
|
||||
}
|
||||
|
||||
QVariant ServerLoggingCategories::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case RoleName:
|
||||
return m_list.at(index.row())->name();
|
||||
case RoleLevel:
|
||||
return m_list.at(index.row())->level();
|
||||
case RoleType:
|
||||
return m_list.at(index.row())->type();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ServerLoggingCategories::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles.insert(RoleName, "name");
|
||||
roles.insert(RoleLevel, "level");
|
||||
roles.insert(RoleType, "type");
|
||||
return roles;
|
||||
}
|
||||
|
||||
void ServerLoggingCategories::createFromVariantList(const QVariantList &loggingCategories)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
if (!m_list.isEmpty())
|
||||
qDeleteAll(m_list);
|
||||
|
||||
foreach(const QVariant &categoryVariant, loggingCategories) {
|
||||
QVariantMap categoryMap = categoryVariant.toMap();
|
||||
ServerLoggingCategory *category = new ServerLoggingCategory(categoryMap, this);
|
||||
|
||||
connect(category, &ServerLoggingCategory::levelChanged, this, [this, category](ServerLoggingCategory::Level level) {
|
||||
Q_UNUSED(level)
|
||||
QModelIndex idx = index(m_list.indexOf(category), 0);
|
||||
emit dataChanged(idx, idx, {RoleLevel});
|
||||
});
|
||||
|
||||
m_list.append(category);
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
65
libnymea-app/serverdebug/serverloggingcategories.h
Normal file
65
libnymea-app/serverdebug/serverloggingcategories.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef SERVERLOGGINGCATEGORIES_H
|
||||
#define SERVERLOGGINGCATEGORIES_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "serverloggingcategory.h"
|
||||
|
||||
class ServerLoggingCategories : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int count READ rowCount CONSTANT)
|
||||
|
||||
public:
|
||||
enum Roles {
|
||||
RoleName,
|
||||
RoleLevel,
|
||||
RoleType
|
||||
};
|
||||
Q_ENUM(Roles)
|
||||
|
||||
explicit ServerLoggingCategories(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
void createFromVariantList(const QVariantList &loggingCategories);
|
||||
|
||||
private:
|
||||
QList<ServerLoggingCategory *> m_list;
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVERLOGGINGCATEGORIES_H
|
||||
102
libnymea-app/serverdebug/serverloggingcategory.cpp
Normal file
102
libnymea-app/serverdebug/serverloggingcategory.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "serverloggingcategory.h"
|
||||
|
||||
ServerLoggingCategory::ServerLoggingCategory(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
ServerLoggingCategory::ServerLoggingCategory(const QVariantMap &loggingCategoryMap, QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
m_name = loggingCategoryMap.value("name").toString();
|
||||
m_level = convertStringToLevel(loggingCategoryMap.value("level").toString());
|
||||
m_type = convertStringToType(loggingCategoryMap.value("type").toString());
|
||||
}
|
||||
|
||||
QString ServerLoggingCategory::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void ServerLoggingCategory::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
ServerLoggingCategory::Type ServerLoggingCategory::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void ServerLoggingCategory::setType(Type type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
ServerLoggingCategory::Level ServerLoggingCategory::level() const
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
|
||||
void ServerLoggingCategory::setLevel(Level level)
|
||||
{
|
||||
if (m_level == level)
|
||||
return;
|
||||
|
||||
m_level = level;
|
||||
emit levelChanged(m_level);
|
||||
}
|
||||
|
||||
ServerLoggingCategory::Level ServerLoggingCategory::convertStringToLevel(const QString &levelString)
|
||||
{
|
||||
Level level = LevelCritical;
|
||||
if (levelString == "LoggingLevelWarning") {
|
||||
level = LevelWarning;
|
||||
} else if (levelString == "LoggingLevelInfo") {
|
||||
level = LevelInfo;
|
||||
} else if (levelString == "LoggingLevelDebug") {
|
||||
level = LevelDebug;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
ServerLoggingCategory::Type ServerLoggingCategory::convertStringToType(const QString &typeString)
|
||||
{
|
||||
Type type = TypeSystem;
|
||||
if (typeString == "LoggingCategoryTypePlugin") {
|
||||
type = TypePlugin;
|
||||
} else if (typeString == "LoggingCategoryTypeCustom") {
|
||||
type = TypeCustom;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
85
libnymea-app/serverdebug/serverloggingcategory.h
Normal file
85
libnymea-app/serverdebug/serverloggingcategory.h
Normal file
@ -0,0 +1,85 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef SERVERLOGGINGCATEGORY_H
|
||||
#define SERVERLOGGINGCATEGORY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
class ServerLoggingCategory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ name CONSTANT FINAL)
|
||||
Q_PROPERTY(ServerLoggingCategory::Type type READ type CONSTANT FINAL)
|
||||
Q_PROPERTY(ServerLoggingCategory::Level level READ level NOTIFY levelChanged FINAL)
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
TypeSystem,
|
||||
TypePlugin,
|
||||
TypeCustom
|
||||
};
|
||||
Q_ENUM(Type)
|
||||
|
||||
enum Level {
|
||||
LevelCritical,
|
||||
LevelWarning,
|
||||
LevelInfo,
|
||||
LevelDebug
|
||||
};
|
||||
Q_ENUM(Level)
|
||||
|
||||
explicit ServerLoggingCategory(QObject *parent = nullptr);
|
||||
explicit ServerLoggingCategory(const QVariantMap &loggingCategoryMap, QObject *parent = nullptr);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
Type type() const;
|
||||
void setType(Type type);
|
||||
|
||||
Level level() const;
|
||||
void setLevel(Level level);
|
||||
|
||||
static Level convertStringToLevel(const QString &levelString);
|
||||
static Type convertStringToType(const QString &typeString);
|
||||
|
||||
signals:
|
||||
void levelChanged(Level level);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
Type m_type;
|
||||
Level m_level;
|
||||
|
||||
};
|
||||
|
||||
#endif // SERVERLOGGINGCATEGORY_H
|
||||
@ -320,5 +320,6 @@
|
||||
<file>ui/customviews/MultiStateChart.qml</file>
|
||||
<file>ui/devicepages/DeviceDetailsPage.qml</file>
|
||||
<file>ui/system/WirelessNetworksFilterSettingsPage.qml</file>
|
||||
<file>ui/system/ServerLoggingCategoriesPage.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@ -115,4 +115,24 @@ SettingsPageBase {
|
||||
}
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
}
|
||||
|
||||
SettingsPageSectionHeader {
|
||||
text: qsTr("Server logging")
|
||||
}
|
||||
|
||||
|
||||
NymeaSwipeDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Server logging categories")
|
||||
progressive: true
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ServerLoggingCategoriesPage.qml"))
|
||||
}
|
||||
|
||||
// NymeaSwipeDelegate {
|
||||
// Layout.fillWidth: true
|
||||
// text: qsTr("Server live logs")
|
||||
// progressive: true
|
||||
// //onClicked: pageStack.push(Qt.resolvedUrl("PluginParamsPage.qml"), {plugin: plugin})
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
137
nymea-app/ui/system/ServerLoggingCategoriesPage.qml
Normal file
137
nymea-app/ui/system/ServerLoggingCategoriesPage.qml
Normal file
@ -0,0 +1,137 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2024, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, GNU version 3. This project is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import Nymea 1.0
|
||||
import "../components"
|
||||
|
||||
SettingsPageBase {
|
||||
header: NymeaHeader {
|
||||
text: qsTr("Server logging categories")
|
||||
backButtonVisible: true
|
||||
onBackPressed: pageStack.pop()
|
||||
}
|
||||
|
||||
ServerDebugManager {
|
||||
id: serverDebugManager
|
||||
engine: _engine
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: root.height
|
||||
visible: serverDebugManager.fetchingData
|
||||
|
||||
BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
visible: serverDebugManager.fetchingData
|
||||
running: visible
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.margins: Style.margins
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Label {
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("Critical")
|
||||
elide: Text.ElideRight
|
||||
font: Style.smallFont
|
||||
}
|
||||
Label {
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("Warning")
|
||||
elide: Text.ElideRight
|
||||
font: Style.smallFont
|
||||
}
|
||||
Label {
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("Info")
|
||||
elide: Text.ElideRight
|
||||
font: Style.smallFont
|
||||
}
|
||||
Label {
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("Debug")
|
||||
elide: Text.ElideRight
|
||||
font: Style.smallFont
|
||||
}
|
||||
}
|
||||
|
||||
ThinDivider {}
|
||||
|
||||
Repeater {
|
||||
model: serverDebugManager.categories
|
||||
delegate: ItemDelegate {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Style.smallDelegateHeight
|
||||
contentItem: RowLayout {
|
||||
height: parent.height
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: model.name
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
RadioButton {
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
checked: model.level === ServerLoggingCategory.LevelCritical
|
||||
onClicked: serverDebugManager.setLoggingLevel(model.name, ServerLoggingCategory.LevelCritical)
|
||||
}
|
||||
RadioButton {
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
checked: model.level === ServerLoggingCategory.LevelWarning
|
||||
onClicked: serverDebugManager.setLoggingLevel(model.name, ServerLoggingCategory.LevelWarning)
|
||||
}
|
||||
RadioButton {
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
checked: model.level === ServerLoggingCategory.LevelInfo
|
||||
onClicked: serverDebugManager.setLoggingLevel(model.name, ServerLoggingCategory.LevelInfo)
|
||||
}
|
||||
RadioButton {
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: Style.smallDelegateHeight
|
||||
checked: model.level === ServerLoggingCategory.LevelDebug
|
||||
onClicked: serverDebugManager.setLoggingLevel(model.name, ServerLoggingCategory.LevelDebug)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user