Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlogging_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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 QLOGGING_P_H
5#define QLOGGING_P_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 for the convenience
12// of a number of Qt sources files. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#include "qlogging.h"
20#include "qloggingcategory.h"
21
22#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(regularexpression)
23# if __has_include(<cxxabi.h>) && QT_CONFIG(backtrace)
24# include <optional>
25# include "qvarlengtharray.h"
26# define QLOGGING_USE_EXECINFO_BACKTRACE
27# define QLOGGING_HAVE_BACKTRACE
28# elif QT_CONFIG(cxx23_stacktrace)
29# include <optional>
30# include <stacktrace>
31# define QLOGGING_USE_STD_BACKTRACE
32# define QLOGGING_HAVE_BACKTRACE
33# endif
34#endif // QT_BOOTSTRAPPED
35
37
38namespace QtPrivate {
39
40Q_CORE_EXPORT bool shouldLogToStderr();
41
42}
43
45{
46public:
47 static constexpr int DefaultBacktraceDepth = 32;
48
49#if defined(QLOGGING_USE_EXECINFO_BACKTRACE)
50 using BacktraceStorage = QVarLengthArray<void *, DefaultBacktraceDepth>;
51#elif defined(QLOGGING_USE_STD_BACKTRACE)
52 using BacktraceStorage = std::stacktrace;
53#else
54 using BacktraceStorage = bool; // dummy
55#endif
56
57 std::optional<BacktraceStorage> backtrace;
58
60 {
61 int backtraceFrames = initFrom(logContext);
62 if (backtraceFrames)
63 populateBacktrace(backtraceFrames);
64 }
66 const QLoggingCategory &categoryOverride)
67 : QInternalMessageLogContext(logContext)
68 {
69 category = categoryOverride.categoryName();
70 }
71
72 int initFrom(const QMessageLogContext &logContext);
73 void populateBacktrace(int frameCount);
74};
75
77
78#endif // QLOGGING_P_H
int initFrom(const QMessageLogContext &logContext)
void populateBacktrace(int frameCount)
QInternalMessageLogContext(const QMessageLogContext &logContext, const QLoggingCategory &categoryOverride)
Definition qlogging_p.h:65
Q_ALWAYS_INLINE QInternalMessageLogContext(const QMessageLogContext &logContext)
Definition qlogging_p.h:59
std::optional< BacktraceStorage > backtrace
Definition qlogging_p.h:57
static constexpr int DefaultBacktraceDepth
Definition qlogging_p.h:47
\inmodule QtCore
\inmodule QtCore
Definition qlogging.h:42
const char * category
Definition qlogging.h:54
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
bool shouldLogToStderr()
Returns true if logging stderr should be ensured.
Definition qlogging.cpp:306
#define Q_ALWAYS_INLINE