QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCLoggingCategoryManager.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QHash>
4#include <QtCore/QObject>
5#include <QtCore/QReadWriteLock>
6#include <QtCore/QSet>
7#include <QtCore/QSortFilterProxyModel>
8#include <QtCore/QString>
9#include <QtQmlIntegration/QtQmlIntegration>
10
11class QJSEngine;
12class QQmlEngine;
15
16class QGCLoggingCategoryManager : public QObject
17{
18 Q_OBJECT
19 QML_ELEMENT
20 QML_SINGLETON
21 Q_MOC_INCLUDE("LoggingCategoryModel.h")
22 Q_PROPERTY(LoggingCategoryTreeModel* treeModel READ treeCategoryModel CONSTANT)
23 Q_PROPERTY(LoggingCategoryFlatModel* flatModel READ flatCategoryModel CONSTANT)
24 Q_PROPERTY(QSortFilterProxyModel* filteredFlatModel READ filteredFlatModel CONSTANT)
25
26public:
27 static QGCLoggingCategoryManager* instance();
28 static void init();
29 static QGCLoggingCategoryManager* create(QQmlEngine* qmlEngine, QJSEngine* jsEngine);
30
31 void registerCategory(const QString& category);
32
33 LoggingCategoryTreeModel* treeCategoryModel() { return _treeModel; }
34
35 LoggingCategoryFlatModel* flatCategoryModel() { return _flatModel; }
36
37 QSortFilterProxyModel* filteredFlatModel() { return &_filteredFlatModel; }
38
39 Q_INVOKABLE void setFilterText(const QString& text);
40
41 Q_INVOKABLE bool isCategoryEnabled(const QString& fullCategoryName) const;
42 int categoryLevel(const QString& fullCategoryName) const;
43 Q_INVOKABLE void setCategoryLevel(const QString& fullCategoryName, int qtMsgLevel);
44 Q_INVOKABLE void setCategoryEnabled(const QString& fullCategoryName, bool enable);
45 void installFilter(const QString& commandLineLoggingOptions = QString());
46 Q_INVOKABLE void disableAllCategories();
47
48private:
50 int _resolvedLevel(const QString& fullCategoryName) const;
51 static void _categoryFilter(QLoggingCategory* category);
52
53 LoggingCategoryTreeModel* _treeModel = nullptr;
54 LoggingCategoryFlatModel* _flatModel = nullptr;
55 QSortFilterProxyModel _filteredFlatModel;
56
57 mutable QReadWriteLock _filterLock;
58 QHash<QString, int> _categoryLevels;
59 QSet<QString> _commandLineCategories;
60 bool _commandLineFullLogging = false;
61
62 static QLoggingCategory::CategoryFilter s_previousFilter;
63 static constexpr const char* kFilterRulesSettingsGroup = "LoggingFilters";
64 static constexpr int kDefaultLevel = QtWarningMsg;
65};