QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LogEntry.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <QtCore/QDateTime>
4
#include <QtCore/QString>
5
#include <QtQmlIntegration/QtQmlIntegration>
6
7
struct
LogEntry
8
{
9
Q_GADGET
10
QML_ANONYMOUS
11
Q_PROPERTY(QDateTime
timestamp
MEMBER
timestamp
FINAL)
12
Q_PROPERTY(
Level
level
MEMBER
level
FINAL)
13
Q_PROPERTY(QString
category
MEMBER
category
FINAL)
14
Q_PROPERTY(QString
message
MEMBER
message
FINAL)
15
Q_PROPERTY(QString
file
MEMBER
file
FINAL)
16
Q_PROPERTY(QString
function
MEMBER
function
FINAL)
17
Q_PROPERTY(QString
formatted
MEMBER
formatted
FINAL)
18
Q_PROPERTY(
int
line
MEMBER
line
FINAL)
19
20
public
:
21
enum
Level
22
{
23
Debug
= 0,
24
Info
= 1,
25
Warning
= 2,
26
Critical
= 3,
27
Fatal
= 4,
28
};
29
Q_ENUM(
Level
)
30
31
LogEntry
() = default;
32
LogEntry
(const
LogEntry
&) = default;
33
LogEntry
(
LogEntry
&&) noexcept = default;
34
LogEntry
& operator=(const
LogEntry
&) = default;
35
LogEntry
& operator=(
LogEntry
&&) noexcept = default;
36
37
QDateTime
timestamp
;
38
Level
level
=
Debug
;
39
QString
category
;
40
QString
message
;
41
QString
file
;
42
QString
function
;
43
QString
formatted
;
44
Qt::HANDLE
threadId
=
nullptr
;
45
int
line
= 0;
46
47
[[nodiscard]] QString
levelLabel
() const;
48
void
buildFormatted
();
49
[[nodiscard]] static
Level
fromQtMsgType
(QtMsgType type);
50
51
// Shared role definitions for all models displaying LogEntry data
52
enum
Role
53
{
54
TimestampRole
= Qt::UserRole + 1,
55
LevelRole
,
56
LevelLabelRole
,
57
CategoryRole
,
58
MessageRole
,
59
FormattedRole
,
60
FileRole
,
61
FunctionRole
,
62
LineRole
,
63
ThreadIdRole
,
64
};
65
66
enum
Column
67
{
68
TimestampColumn
= 0,
69
LevelColumn
,
70
CategoryColumn
,
71
SourceColumn
,
72
MessageColumn
,
73
ColumnCount
74
};
75
Q_ENUM(
Column
)
76
77
[[nodiscard]]
static
QHash<int, QByteArray>
roleNames
();
78
[[nodiscard]] QVariant
roleData
(
int
role)
const
;
79
[[nodiscard]] QVariant
columnDisplayData
(
int
column)
const
;
80
[[nodiscard]]
static
QVariant
columnHeaderData
(
int
section);
81
};
82
83
// Expose LogEntry enums to QML under the uppercase "LogEntry" name.
84
// Q_NAMESPACE + QML_NAMED_ELEMENT registers as a namespace (not a value type),
85
// so the lowercase-name warning does not apply.
86
namespace
LogEntryForeign
87
{
88
Q_NAMESPACE
89
QML_NAMED_ELEMENT(
LogEntry
)
90
QML_FOREIGN_NAMESPACE(
LogEntry
)
91
}
LogEntryForeign
Definition
LogEntry.h:87
LogEntry
Definition
LogEntry.h:8
LogEntry::columnHeaderData
static QVariant columnHeaderData(int section)
Definition
LogEntry.cc:113
LogEntry::Role
Role
Definition
LogEntry.h:53
LogEntry::LevelRole
@ LevelRole
Definition
LogEntry.h:55
LogEntry::LineRole
@ LineRole
Definition
LogEntry.h:62
LogEntry::LevelLabelRole
@ LevelLabelRole
Definition
LogEntry.h:56
LogEntry::FileRole
@ FileRole
Definition
LogEntry.h:60
LogEntry::TimestampRole
@ TimestampRole
Definition
LogEntry.h:54
LogEntry::ThreadIdRole
@ ThreadIdRole
Definition
LogEntry.h:63
LogEntry::CategoryRole
@ CategoryRole
Definition
LogEntry.h:57
LogEntry::MessageRole
@ MessageRole
Definition
LogEntry.h:58
LogEntry::FormattedRole
@ FormattedRole
Definition
LogEntry.h:59
LogEntry::FunctionRole
@ FunctionRole
Definition
LogEntry.h:61
LogEntry::file
QString file
Definition
LogEntry.h:41
LogEntry::function
QString function
Definition
LogEntry.h:42
LogEntry::line
int line
Definition
LogEntry.h:45
LogEntry::message
QString message
Definition
LogEntry.h:40
LogEntry::columnDisplayData
QVariant columnDisplayData(int column) const
Definition
LogEntry.cc:91
LogEntry::timestamp
QDateTime timestamp
Definition
LogEntry.h:37
LogEntry::roleData
QVariant roleData(int role) const
Definition
LogEntry.cc:64
LogEntry::levelLabel
QString levelLabel() const
Definition
LogEntry.cc:7
LogEntry::formatted
QString formatted
Definition
LogEntry.h:43
LogEntry::roleNames
static QHash< int, QByteArray > roleNames()
Definition
LogEntry.cc:46
LogEntry::fromQtMsgType
static Level fromQtMsgType(QtMsgType type)
Definition
LogEntry.cc:29
LogEntry::level
Level level
Definition
LogEntry.h:38
LogEntry::category
QString category
Definition
LogEntry.h:39
LogEntry::Column
Column
Definition
LogEntry.h:67
LogEntry::MessageColumn
@ MessageColumn
Definition
LogEntry.h:72
LogEntry::TimestampColumn
@ TimestampColumn
Definition
LogEntry.h:68
LogEntry::ColumnCount
@ ColumnCount
Definition
LogEntry.h:73
LogEntry::CategoryColumn
@ CategoryColumn
Definition
LogEntry.h:70
LogEntry::LevelColumn
@ LevelColumn
Definition
LogEntry.h:69
LogEntry::SourceColumn
@ SourceColumn
Definition
LogEntry.h:71
LogEntry::Level
Level
Definition
LogEntry.h:22
LogEntry::Info
@ Info
Definition
LogEntry.h:24
LogEntry::Debug
@ Debug
Definition
LogEntry.h:23
LogEntry::Critical
@ Critical
Definition
LogEntry.h:26
LogEntry::Fatal
@ Fatal
Definition
LogEntry.h:27
LogEntry::Warning
@ Warning
Definition
LogEntry.h:25
LogEntry::threadId
Qt::HANDLE threadId
Definition
LogEntry.h:44
LogEntry::buildFormatted
void buildFormatted()
Definition
LogEntry.cc:23
src
LogManager
LogEntry.h
Generated by
1.9.8