5#include <QtCore/QLoggingCategory>
6#include <QtCore/QString>
7#include <QtCore/QStringListModel>
8#include <QtCore/QTimer>
15 QtMsgType type = QtDebugMsg;
25 explicit QGCLogging(QObject *parent =
nullptr);
38 void log(
const QString &message);
54 [[nodiscard]]
static QList<CapturedLogMessage>
capturedMessages(
const QString &category = {});
71 static void captureIfEnabled(QtMsgType type,
const QMessageLogContext &context,
const QString &msg);
85 void _threadsafeLog(
const QString &message);
95 QStringList _pendingDiskWrites;
96 bool _ioError =
false;
98 static constexpr int kMaxLogFileSize = 10LL * 1024 * 1024;
99 static constexpr int kMaxBackupFiles = 5;
100 static constexpr int kFlushIntervalMSecs = 1000;
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
static void setCaptureEnabled(bool enabled)
static bool hasCapturedMessage(const QString &category, QtMsgType type)
void log(const QString &message)
Enqueue a log message (thread-safe)
void writeMessages(const QString &destFile)
Write current log messages to a file asynchronously.
static bool hasCapturedCritical(const QString &category)
Convenience: captured critical in category?
static QList< CapturedLogMessage > capturedMessages(const QString &category={})
static QGCLogging * instance()
Get the singleton instance.
static void installHandler()
Install Qt message handler to route logs through this class.
static void clearCapturedMessages()
Discard all previously captured messages.
void writeFinished(bool success)
Emitted when file write finishes (success flag)
static void captureIfEnabled(QtMsgType type, const QMessageLogContext &context, const QString &msg)
void emitLog(const QString &message)
Emitted when a log message is enqueued.
static bool hasCapturedWarning(const QString &category)
Convenience: captured warning in category?
void writeStarted()
Emitted when file write starts.
static bool hasCapturedUncategorizedMessage()
Return true if any uncategorized message was captured (e.g. raw qDebug/qWarning).
A single captured log message for test introspection.