LibDS
Qt-based library for controlling FRC robots
Public Slots | Signals | Public Member Functions | Private Slots | Private Attributes | List of all members
Logger Class Reference

Creates and reads files with robot events and application logs. More...

#include <Logger.h>

Inheritance diagram for Logger:

Public Slots

void saveLogs ()
 
void closeLogs ()
 
void registerInitialEvents ()
 
void registerVoltage (qreal voltage)
 
void registerPacketLoss (int pktLoss)
 
void registerRobotRAMUsage (int usage)
 
void registerRobotCPUUsage (int usage)
 
void registerAlliance (DS::Alliance alliance)
 
void registerPosition (DS::Position position)
 
void registerControlMode (DS::ControlMode mode)
 
void registerCodeStatus (DS::CodeStatus status)
 
void registerEnableStatus (DS::EnableStatus status)
 
void registerRadioCommStatus (DS::CommStatus status)
 
void registerRobotCommStatus (DS::CommStatus status)
 
void registerVoltageStatus (DS::VoltageStatus status)
 
void registerNetConsoleMessage (const QString &message)
 
void registerOperationStatus (DS::OperationStatus status)
 

Signals

void logsSaved (const QString &file)
 

Public Member Functions

QString logsPath () const
 
QString extension () const
 
QStringList availableLogs () const
 
QJsonDocument openLog (const QString &name) const
 
void messageHandler (QtMsgType type, const QMessageLogContext &context, const QString &data)
 

Private Slots

void initializeLogger ()
 

Private Attributes

QString m_netConsole
 
QElapsedTimer * m_timer
 
bool m_eventsRegistered
 
FILE * m_dump
 
bool m_closed
 
bool m_initialized
 
QString m_logFilePath
 
QString m_dumpFilePath
 
int m_previousRAM
 
int m_previousCPU
 
int m_previousLoss
 
qreal m_previousVoltage
 
DS::CodeStatus m_previousCodeStatus
 
DS::ControlMode m_previousControlMode
 
DS::CommStatus m_previousRadioCommStatus
 
DS::CommStatus m_previousRobotCommStatus
 
DS::EnableStatus m_previousEnabledStatus
 
DS::VoltageStatus m_previousVoltageStatus
 
DS::OperationStatus m_previousOperationStatus
 
QList< QPair< qint64, int > > m_pktLoss
 
QList< QPair< qint64, int > > m_ramUsage
 
QList< QPair< qint64, int > > m_cpuUsage
 
QList< QPair< qint64, qreal > > m_voltage
 
QList< QPair< qint64, DS::CodeStatus > > m_codeStatus
 
QList< QPair< qint64, DS::ControlMode > > m_controlMode
 
QList< QPair< qint64, DS::CommStatus > > m_radioCommStatus
 
QList< QPair< qint64, DS::CommStatus > > m_robotCommStatus
 
QList< QPair< qint64, DS::EnableStatus > > m_enabledStatus
 
QList< QPair< qint64, DS::VoltageStatus > > m_voltageStatus
 
QList< QPair< qint64, DS::OperationStatus > > m_operationStatus
 

Detailed Description

Creates and reads files with robot events and application logs.

This can be later used to diagnostic the robot or to diagnostic the QDriverStation.

Member Function Documentation

QStringList Logger::availableLogs ( ) const

Returns a list with all the logs that have been created locally

References extension(), and logsPath().

Referenced by DriverStation::availableLogs().

void Logger::closeLogs ( )
slot

Closes the console log dump file

References saveLogs().

QString Logger::extension ( ) const

Returns the extension appended to the log files

Referenced by availableLogs(), and DriverStation::browseLogs().

void Logger::initializeLogger ( )
privateslot

Creates the temporary console dump file and sets the file name of the final DS log file.

Note
The OS name, version and date/time will be registered in the log
The application name and version are also registered in the log

References saveLogs().

Referenced by messageHandler().

QString Logger::logsPath ( ) const

Returns the path in which log files are saved

Referenced by availableLogs(), and DriverStation::logsPath().

void Logger::messageHandler ( QtMsgType  type,
const QMessageLogContext &  context,
const QString &  data 
)

Writes the message output to the console and to the dump file (which is dumped on the DS log file when the application exits).

References initializeLogger().

Referenced by DriverStation::logger().

QJsonDocument Logger::openLog ( const QString &  name) const

Opens the given log file and parses its JSON data

Referenced by DriverStation::openLog().

void Logger::registerAlliance ( DS::Alliance  alliance)
slot

Logs the given team alliance to the console output.

Referenced by registerInitialEvents(), and DS_Config::updateAlliance().

void Logger::registerCodeStatus ( DS::CodeStatus  status)
slot

Registers the given code status to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateRobotCodeStatus().

void Logger::registerControlMode ( DS::ControlMode  mode)
slot

Registers the given control mode to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateControlMode().

void Logger::registerEnableStatus ( DS::EnableStatus  status)
slot

Registers the given enable status to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateEnabled().

void Logger::registerInitialEvents ( )
slot
void Logger::registerNetConsoleMessage ( const QString &  message)
slot

Appends the given message to the NetConsole log

void Logger::registerOperationStatus ( DS::OperationStatus  status)
slot

Registers the given operation status to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateOperationStatus().

void Logger::registerPacketLoss ( int  pktLoss)
slot

Registers the given packet loss to the robot events log.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DriverStation::updatePacketLoss().

void Logger::registerPosition ( DS::Position  position)
slot

Logs the given team position to the console output.

Referenced by DS_Config::updatePosition().

void Logger::registerRadioCommStatus ( DS::CommStatus  status)
slot

Registers the given radio communication status to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateRadioCommStatus().

void Logger::registerRobotCommStatus ( DS::CommStatus  status)
slot

Registers the given robot communication status to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateRobotCommStatus().

void Logger::registerRobotCPUUsage ( int  usage)
slot

Registers the given CPU usage to the robot events log.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents().

void Logger::registerRobotRAMUsage ( int  usage)
slot

Registers the given RAM usage to the robot events log.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents().

void Logger::registerVoltage ( qreal  voltage)
slot

Registers the given voltage to the robot events log.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateVoltage().

void Logger::registerVoltageStatus ( DS::VoltageStatus  status)
slot

Registers the given voltage status to the event lists.

Note
This value will only be registered if the given data is different from the data registered earlier (to avoid creating huge log files)

Referenced by registerInitialEvents(), and DS_Config::updateVoltageStatus().

void Logger::saveLogs ( )
slot

Saves the robot events and the application logs into a compact JSON file. This file can later be used by teams to diagnostic their robots or by the LibDS developers to fix an issue.

Referenced by closeLogs(), and initializeLogger().


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