|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <StateMachineLogger.h>
Inheritance diagram for StateMachineLogger:
Collaboration diagram for StateMachineLogger:Classes | |
| struct | LogEntry |
| Structured log entry. More... | |
Public Types | |
| enum | LogLevel { Silent = 0 , Error = 1 , Normal = 2 , Verbose = 3 , Trace = 4 } |
| Log verbosity levels. More... | |
| enum | LogEvent { EventNone = 0 , EventStateEntry = 1 << 0 , EventStateExit = 1 << 1 , EventTransition = 1 << 2 , EventSignal = 1 << 3 , EventTimeout = 1 << 4 , EventError = 1 << 5 , EventMachineStart = 1 << 6 , EventMachineStop = 1 << 7 , EventRetry = 1 << 8 , EventProgress = 1 << 9 , EventCustom = 1 << 10 , EventAll = 0xFFFF , EventStateChanges = EventStateEntry | EventStateExit , EventMachineEvents = EventMachineStart | EventMachineStop , EventErrors = EventError | EventTimeout } |
| Types of log events. More... | |
| using | LogHandler = std::function< void(const LogEntry &)> |
Public Member Functions | |
| StateMachineLogger (QGCStateMachine *machine, QObject *parent=nullptr) | |
| ~StateMachineLogger () override | |
| void | setEnabled (bool enabled) |
| bool | isEnabled () const |
| void | setLogLevel (LogLevel level) |
| LogLevel | logLevel () const |
| void | setStateLogLevel (const QString &stateName, LogLevel level) |
| Set log level override for a specific state. | |
| void | clearStateLogLevel (const QString &stateName) |
| void | setLogFilter (LogEvents events) |
| Set which events to log (default: all) | |
| LogEvents | logFilter () const |
| void | excludeState (const QString &stateName) |
| Exclude specific states from logging. | |
| void | includeState (const QString &stateName) |
| void | clearExclusions () |
| void | setColoredOutput (bool enabled) |
| Enable colored console output. | |
| bool | coloredOutput () const |
| void | setLogTimings (bool enabled) |
| Enable timing annotations. | |
| bool | logTimings () const |
| void | setLogIndent (bool enabled) |
| Enable hierarchy indentation. | |
| bool | logIndent () const |
| void | setLogTransitionReasons (bool enabled) |
| Log transition reasons (signal name, timeout, etc.) | |
| bool | logTransitionReasons () const |
| bool | setLogFile (const QString &filePath) |
| Log to a file (in addition to console) | |
| void | closeLogFile () |
| void | setLogHandler (LogHandler handler) |
| Set a custom log handler. | |
| void | enableCrashLog (int maxEntries) |
| Enable crash log buffer (circular buffer for post-mortem analysis) | |
| void | disableCrashLog () |
| QString | dumpCrashLog () const |
| QList< LogEntry > | crashLogEntries () const |
| void | log (LogLevel level, const QString &message, const QJsonObject &context=QJsonObject()) |
| Log a custom message. | |
| void | logEvent (LogEvent event, const QString &message, const QJsonObject &context=QJsonObject()) |
| Log with specific event type. | |
| QHash< LogEvent, int > | eventCounts () const |
| Get count of entries by event type. | |
| void | resetStats () |
| Reset statistics. | |
Extended logging for state machines.
Provides configurable, structured logging with multiple output options.
Example usage:
Definition at line 37 of file StateMachineLogger.h.
| using StateMachineLogger::LogHandler = std::function<void(const LogEntry&)> |
Definition at line 93 of file StateMachineLogger.h.
Types of log events.
Definition at line 53 of file StateMachineLogger.h.
Log verbosity levels.
| Enumerator | |
|---|---|
| Silent | No logging. |
| Error | Only errors. |
| Normal | Errors + state changes. |
| Verbose | Normal + signals/transitions. |
| Trace | Everything including internal details. |
Definition at line 43 of file StateMachineLogger.h.
|
explicit |
Definition at line 167 of file StateMachineLogger.cc.
|
override |
Definition at line 173 of file StateMachineLogger.cc.
References closeLogFile().
|
inline |
Definition at line 127 of file StateMachineLogger.h.
| void StateMachineLogger::clearStateLogLevel | ( | const QString & | stateName | ) |
Definition at line 224 of file StateMachineLogger.cc.
| void StateMachineLogger::closeLogFile | ( | ) |
Definition at line 254 of file StateMachineLogger.cc.
Referenced by setLogFile(), and ~StateMachineLogger().
|
inline |
Definition at line 135 of file StateMachineLogger.h.
|
inline |
Definition at line 164 of file StateMachineLogger.h.
| void StateMachineLogger::disableCrashLog | ( | ) |
Definition at line 273 of file StateMachineLogger.cc.
| QString StateMachineLogger::dumpCrashLog | ( | ) | const |
Definition at line 279 of file StateMachineLogger.cc.
| void StateMachineLogger::enableCrashLog | ( | int | maxEntries | ) |
Enable crash log buffer (circular buffer for post-mortem analysis)
Definition at line 267 of file StateMachineLogger.cc.
|
inline |
Get count of entries by event type.
Definition at line 181 of file StateMachineLogger.h.
| void StateMachineLogger::excludeState | ( | const QString & | stateName | ) |
Exclude specific states from logging.
Definition at line 229 of file StateMachineLogger.cc.
| void StateMachineLogger::includeState | ( | const QString & | stateName | ) |
Definition at line 234 of file StateMachineLogger.cc.
|
inline |
Definition at line 103 of file StateMachineLogger.h.
| void StateMachineLogger::log | ( | LogLevel | level, |
| const QString & | message, | ||
| const QJsonObject & | context = QJsonObject() |
||
| ) |
Log a custom message.
Definition at line 293 of file StateMachineLogger.cc.
References StateMachineLogger::LogEntry::context, StateMachineLogger::LogEntry::depth, StateMachineLogger::LogEntry::elapsedMs, StateMachineLogger::LogEntry::event, EventCustom, StateMachineLogger::LogEntry::level, StateMachineLogger::LogEntry::machine, StateMachineLogger::LogEntry::message, and StateMachineLogger::LogEntry::timestamp.
| void StateMachineLogger::logEvent | ( | LogEvent | event, |
| const QString & | message, | ||
| const QJsonObject & | context = QJsonObject() |
||
| ) |
Log with specific event type.
Definition at line 312 of file StateMachineLogger.cc.
References StateMachineLogger::LogEntry::context, StateMachineLogger::LogEntry::depth, StateMachineLogger::LogEntry::elapsedMs, StateMachineLogger::LogEntry::event, EventProgress, EventSignal, StateMachineLogger::LogEntry::level, StateMachineLogger::LogEntry::machine, StateMachineLogger::LogEntry::message, Normal, StateMachineLogger::LogEntry::timestamp, and Verbose.
|
inline |
Definition at line 122 of file StateMachineLogger.h.
|
inline |
Definition at line 143 of file StateMachineLogger.h.
|
inline |
Definition at line 110 of file StateMachineLogger.h.
|
inline |
Definition at line 139 of file StateMachineLogger.h.
|
inline |
Definition at line 147 of file StateMachineLogger.h.
|
inline |
Reset statistics.
Definition at line 184 of file StateMachineLogger.h.
|
inline |
Enable colored console output.
Definition at line 134 of file StateMachineLogger.h.
| void StateMachineLogger::setEnabled | ( | bool | enabled | ) |
Definition at line 178 of file StateMachineLogger.cc.
| bool StateMachineLogger::setLogFile | ( | const QString & | filePath | ) |
Log to a file (in addition to console)
Definition at line 239 of file StateMachineLogger.cc.
References closeLogFile().
|
inline |
Set which events to log (default: all)
Definition at line 121 of file StateMachineLogger.h.
|
inline |
Set a custom log handler.
Definition at line 158 of file StateMachineLogger.h.
|
inline |
Enable hierarchy indentation.
Definition at line 142 of file StateMachineLogger.h.
|
inline |
Definition at line 109 of file StateMachineLogger.h.
|
inline |
Enable timing annotations.
Definition at line 138 of file StateMachineLogger.h.
|
inline |
Log transition reasons (signal name, timeout, etc.)
Definition at line 146 of file StateMachineLogger.h.
| void StateMachineLogger::setStateLogLevel | ( | const QString & | stateName, |
| LogLevel | level | ||
| ) |
Set log level override for a specific state.
Definition at line 219 of file StateMachineLogger.cc.