Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qohoslogger_p.h
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QOHOSLOGGER_H
5
#
define
QOHOSLOGGER_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtCore
/
qdebug
.
h
>
19
#
include
<
QtCore
/
qloggingcategory
.
h
>
20
#
include
<
QtCore
/
qthread
.
h
>
21
#
include
<
cstdarg
>
22
#
include
<
hilog
/
log
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(QtForOhos, Q_CORE_EXPORT)
27
28
#
define
qOhosDebug
(
category
)
29
_Pragma
(
"GCC diagnostic push"
)
30
_Pragma
(
"GCC diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\""
)
31
qCDebug
(
category
)
32
_Pragma
(
"GCC diagnostic pop"
)
33
34
#
define
qOhosWarning
(
category
)
35
_Pragma
(
"GCC diagnostic push"
)
36
_Pragma
(
"GCC diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\""
)
37
qCWarning
(
category
)
38
_Pragma
(
"GCC diagnostic pop"
)
39
40
#
define
qOhosCritical
(
category
)
41
_Pragma
(
"GCC diagnostic push"
)
42
_Pragma
(
"GCC diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\""
)
43
qCCritical
(
category
)
44
_Pragma
(
"GCC diagnostic pop"
)
45
46
#
define
qOhosFatal
(
category
)
47
_Pragma
(
"GCC diagnostic push"
)
48
_Pragma
(
"GCC diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\""
)
49
qCFatal
(
category
)
50
_Pragma
(
"GCC diagnostic pop"
)
51
52
Q_CORE_EXPORT
void
qOhosLogMessage(LogLevel logLevel,
const
char
*tag,
const
char
*message);
53
54
Q_CORE_EXPORT
Q_ATTRIBUTE_FORMAT_PRINTF
(2, 0)
void
qOhosVPrintf
(LogLevel logLevel,
const
char
*
format
,
std
::
va_list
ap
);
55
56
Q_ATTRIBUTE_FORMAT_PRINTF
(1, 2)
inline
void
qOhosPrintfDebug(
const
char
*format, ...)
57
{
58
std::va_list ap;
59
va_start(ap, format);
60
qOhosVPrintf(LOG_DEBUG, format, ap);
61
va_end(ap);
62
}
63
64
Q_ATTRIBUTE_FORMAT_PRINTF
(1, 2)
inline
void
qOhosPrintfInfo(
const
char
*format, ...)
65
{
66
std::va_list ap;
67
va_start(ap, format);
68
qOhosVPrintf(LOG_INFO, format, ap);
69
va_end(ap);
70
}
71
72
Q_ATTRIBUTE_FORMAT_PRINTF
(1, 2)
inline
void
qOhosPrintfWarning(
const
char
*format, ...)
73
{
74
std::va_list ap;
75
va_start(ap, format);
76
qOhosVPrintf(LOG_WARN, format, ap);
77
va_end(ap);
78
}
79
80
Q_ATTRIBUTE_FORMAT_PRINTF
(1, 2)
inline
void
qOhosPrintfError(
const
char
*format, ...)
81
{
82
std::va_list ap;
83
va_start(ap, format);
84
qOhosVPrintf(LOG_ERROR, format, ap);
85
va_end(ap);
86
}
87
88
template
<
typename
StringType>
89
struct
QCScopedDebug
90
{
91
QCScopedDebug
(StringType message):
92
m_message(message)
93
{
qOhosDebug
(QtForOhos) <<
"T:"
<< QThread::currentThreadId() <<
", M:"
<< message <<
"begin"
;}
94
95
~
QCScopedDebug
() {
qOhosDebug
(QtForOhos) <<
"T:"
<< QThread::currentThreadId() <<
", M:"
<< m_message
96
<<
"end"
;}
97
private
:
98
StringType m_message;
99
};
100
101
template
<
typename
StringType>
102
struct
QCScopedDebugJS
103
{
104
QCScopedDebugJS
(StringType message): m_message(message) {qOhosPrintfDebug(
"%s begin"
, message);}
105
~
QCScopedDebugJS
() {qOhosPrintfDebug(
"%s end"
, m_message);}
106
107
private
:
108
StringType m_message;
109
};
110
111
template
<
typename
StringType>
112
auto
make_QCScopedDebug(StringType&& message) -> QCScopedDebug<
typename
std::decay<StringType>::type> {
113
return
{std::forward<StringType>(message)};
114
}
115
116
template
<
typename
StringType>
117
auto
make_QCScopedDebugJS(StringType&& message) -> QCScopedDebugJS<
typename
std::decay<StringType>::type> {
118
return
{std::forward<StringType>(message)};
119
}
120
121
#
define
DUMP
(
x
)
qOhosDebug
(
QtForOhos
)
<<
"T:"
<<
QThread
::
currentThreadId
(
)
<<
#
x
<<
x
;
122
123
QT_END_NAMESPACE
124
125
#
endif
// QOHOSLOGGER_H
qOhosVPrintf
void qOhosVPrintf(LogLevel logLevel, const char *format, std::va_list ap)
Definition
qohoslogger.cpp:18
Q_ATTRIBUTE_FORMAT_PRINTF
Q_CORE_EXPORT Q_ATTRIBUTE_FORMAT_PRINTF(2, 0) void qOhosVPrintf(LogLevel logLevel
qOhosDebug
#define qOhosDebug(category)
Definition
qohoslogger_p.h:28
format
Q_CORE_EXPORT const char * format
Definition
qohoslogger_p.h:54
ap
Q_CORE_EXPORT const char std::va_list ap
Definition
qohoslogger_p.h:54
QCScopedDebugJS
Definition
qohoslogger_p.h:103
QCScopedDebugJS::QCScopedDebugJS
QCScopedDebugJS(StringType message)
Definition
qohoslogger_p.h:104
QCScopedDebugJS::~QCScopedDebugJS
~QCScopedDebugJS()
Definition
qohoslogger_p.h:105
QCScopedDebug
Definition
qohoslogger_p.h:90
QCScopedDebug::QCScopedDebug
QCScopedDebug(StringType message)
Definition
qohoslogger_p.h:91
QCScopedDebug::~QCScopedDebug
~QCScopedDebug()
Definition
qohoslogger_p.h:95
qtbase
src
corelib
platform
ohos
qohoslogger_p.h
Generated on
for Qt by
1.18.0