QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCLoggingCategory.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <QtCore/QLoggingCategory>
6#include <QtCore/QObject>
7#include <QtCore/QStringList>
8#include <QtCore/QMap>
9
11
14#define QGC_LOGGING_CATEGORY(name, categoryStr) \
15 static QGCLoggingCategory qgcCategory ## name (categoryStr); \
16 Q_LOGGING_CATEGORY(name, categoryStr, QtWarningMsg)
17
18#define QGC_LOGGING_CATEGORY_ON(name, categoryStr) \
19 static QGCLoggingCategory qgcCategory ## name (categoryStr); \
20 Q_LOGGING_CATEGORY(name, categoryStr, QtInfoMsg)
21
22class QGCLoggingCategoryManager : public QObject
23{
24 Q_GADGET
25
26public:
28
30 void registerCategory(const QString &category);
31
33 QmlObjectListModel *treeCategoryModel() { return &_treeCategoryModel; }
34
36 QmlObjectListModel *flatCategoryModel() { return &_flatCategoryModel; }
37
39 static bool categoryLoggingOn(const QString &fullCategroryName);
40
43 void setFilterRulesFromSettings(const QString &commandLineLoggingOptions);
44
46
47public slots:
49 void setCategoryLoggingOn(const QString &fullCategoryName, bool enable);
50
51private:
52 static void _splitFullCategoryName(const QString &fullCategoryName, QString &parentCategory, QString &childCategory);
53 QGCLoggingCategoryItem *_findLoggingCategory(const QString &fullCategoryName);
54 void _insertSorted(QmlObjectListModel* model, QGCLoggingCategoryItem* item);
55
56 QmlObjectListModel _treeCategoryModel;
57 QmlObjectListModel _flatCategoryModel;
58
59 static constexpr const char *kFilterRulesSettingsGroup = "LoggingFilters";
60};
61
62/*===========================================================================*/
63
65{
66public:
68};
69
70class QGCLoggingCategoryItem : public QObject
71{
72 Q_OBJECT
73
74 Q_PROPERTY(QString shortCategory MEMBER shortCategory CONSTANT)
75 Q_PROPERTY(QString fullCategory MEMBER fullCategory CONSTANT)
76 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
77 Q_PROPERTY(bool expanded MEMBER expanded NOTIFY expandedChanged)
78 Q_PROPERTY(QmlObjectListModel* children MEMBER children CONSTANT)
79
80public:
81 QGCLoggingCategoryItem(const QString& shortCategory_, const QString& fullCategory_, bool enabled_, QObject* parent = nullptr);
82
83 bool enabled() const { return _enabled; }
84 void setEnabled(bool enabled);
85
86 QString shortCategory;
87 QString fullCategory;
88 bool _enabled = false;
89 bool expanded = false;
90 QmlObjectListModel* children = nullptr;
91
92signals:
95};
void registerCategory(const QString &category)
Registers the specified logging category to the system.
static bool categoryLoggingOn(const QString &fullCategroryName)
Returns true if logging is turned on for the specified category.
QmlObjectListModel * treeCategoryModel()
Returns the hierarchical list of available logging category names.
static QGCLoggingCategoryManager * instance()
QmlObjectListModel * flatCategoryModel()
Returns the flat list of available logging category names.
void setCategoryLoggingOn(const QString &fullCategoryName, bool enable)
Turns on/off logging for the specified category. State is saved in app settings.
void setFilterRulesFromSettings(const QString &commandLineLoggingOptions)
QGCLoggingCategory(const QString &category)