QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCLogging Class Reference

#include <QGCLogging.h>

+ Inheritance diagram for QGCLogging:
+ Collaboration diagram for QGCLogging:

Signals

void emitLog (const QString &message)
 Emitted when a log message is enqueued.
 
void writeStarted ()
 Emitted when file write starts.
 
void writeFinished (bool success)
 Emitted when file write finishes (success flag)
 

Public Member Functions

 QGCLogging (QObject *parent=nullptr)
 
 ~QGCLogging ()
 
void writeMessages (const QString &destFile)
 Write current log messages to a file asynchronously.
 
void log (const QString &message)
 Enqueue a log message (thread-safe)
 

Static Public Member Functions

static QGCLogginginstance ()
 Get the singleton instance.
 
static void installHandler ()
 Install Qt message handler to route logs through this class.
 
static void setCaptureEnabled (bool enabled)
 
static void clearCapturedMessages ()
 Discard all previously captured messages.
 
static QList< CapturedLogMessagecapturedMessages (const QString &category={})
 
static bool hasCapturedMessage (const QString &category, QtMsgType type)
 
static bool hasCapturedWarning (const QString &category)
 Convenience: captured warning in category?
 
static bool hasCapturedCritical (const QString &category)
 Convenience: captured critical in category?
 
static bool hasCapturedUncategorizedMessage ()
 Return true if any uncategorized message was captured (e.g. raw qDebug/qWarning).
 
static void captureIfEnabled (QtMsgType type, const QMessageLogContext &context, const QString &msg)
 

Detailed Description

Definition at line 20 of file QGCLogging.h.

Constructor & Destructor Documentation

◆ QGCLogging()

QGCLogging::QGCLogging ( QObject *  parent = nullptr)
explicit

Definition at line 55 of file QGCLogging.cc.

References emitLog().

◆ ~QGCLogging()

QGCLogging::~QGCLogging ( )

Definition at line 74 of file QGCLogging.cc.

Member Function Documentation

◆ capturedMessages()

QList< CapturedLogMessage > QGCLogging::capturedMessages ( const QString &  category = {})
static

Return captured messages, optionally filtered to a single category. Pass an empty string to retrieve all messages.

Definition at line 103 of file QGCLogging.cc.

References s_capturedMessages, and s_captureMutex.

◆ captureIfEnabled()

void QGCLogging::captureIfEnabled ( QtMsgType  type,
const QMessageLogContext &  context,
const QString &  msg 
)
static

Record a message into the capture buffer (if capture is enabled). Intended for external handler wrappers (e.g. the unit-test capture handler).

Definition at line 154 of file QGCLogging.cc.

References s_capturedMessages, s_captureEnabled, and s_captureMutex.

Referenced by msgHandler().

◆ clearCapturedMessages()

void QGCLogging::clearCapturedMessages ( )
static

Discard all previously captured messages.

Definition at line 97 of file QGCLogging.cc.

References s_capturedMessages, and s_captureMutex.

◆ emitLog

void QGCLogging::emitLog ( const QString &  message)
signal

Emitted when a log message is enqueued.

Referenced by log(), and QGCLogging().

◆ hasCapturedCritical()

bool QGCLogging::hasCapturedCritical ( const QString &  category)
static

Convenience: captured critical in category?

Definition at line 137 of file QGCLogging.cc.

References hasCapturedMessage().

◆ hasCapturedMessage()

bool QGCLogging::hasCapturedMessage ( const QString &  category,
QtMsgType  type 
)
static

Return true if at least one message of the given type was captured for category.

Definition at line 120 of file QGCLogging.cc.

References s_capturedMessages, and s_captureMutex.

Referenced by hasCapturedCritical(), and hasCapturedWarning().

◆ hasCapturedUncategorizedMessage()

bool QGCLogging::hasCapturedUncategorizedMessage ( )
static

Return true if any uncategorized message was captured (e.g. raw qDebug/qWarning).

Definition at line 142 of file QGCLogging.cc.

References s_capturedMessages, and s_captureMutex.

◆ hasCapturedWarning()

bool QGCLogging::hasCapturedWarning ( const QString &  category)
static

Convenience: captured warning in category?

Definition at line 132 of file QGCLogging.cc.

References hasCapturedMessage().

◆ installHandler()

void QGCLogging::installHandler ( )
static

Install Qt message handler to route logs through this class.

Definition at line 79 of file QGCLogging.cc.

References msgHandler().

Referenced by main().

◆ instance()

QGCLogging * QGCLogging::instance ( )
static

Get the singleton instance.

Definition at line 50 of file QGCLogging.cc.

Referenced by msgHandler().

◆ log()

void QGCLogging::log ( const QString &  message)

Enqueue a log message (thread-safe)

Definition at line 166 of file QGCLogging.cc.

References emitLog().

Referenced by msgHandler().

◆ setCaptureEnabled()

void QGCLogging::setCaptureEnabled ( bool  enabled)
static

Enable or disable log capture (for unit testing). When enabled, every message passing through the Qt message handler is recorded with its category, type and raw text.

Definition at line 92 of file QGCLogging.cc.

References s_captureEnabled.

◆ writeFinished

void QGCLogging::writeFinished ( bool  success)
signal

Emitted when file write finishes (success flag)

Referenced by writeMessages().

◆ writeMessages()

void QGCLogging::writeMessages ( const QString &  destFile)

Write current log messages to a file asynchronously.

Definition at line 277 of file QGCLogging.cc.

References writeFinished(), and writeStarted().

◆ writeStarted

void QGCLogging::writeStarted ( )
signal

Emitted when file write starts.

Referenced by writeMessages().


The documentation for this class was generated from the following files: