WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Zbl::ZblLogWorker Class Reference

This class provides a thread-safe log message back end for the Zuble log manager. More...

#include <ZblLogWorker.h>

Inheritance diagram for Zbl::ZblLogWorker:
Inheritance graph
[legend]
Collaboration diagram for Zbl::ZblLogWorker:
Collaboration graph
[legend]

Public Slots

bool zInit (const QString &logSource, ZTableModel *logBuffer)
 Initializes the ZblLogWorker object. This method should be called after the ZblLogWorker object has been moved to it's host thread. It should be called only once prior to calling any other methods on this object. More...
 
void outputLogMessage (QVariant message)
 Outputs a log message to the log histogram buffer and/or a file and/or stdout. More...
 
void setOutputParameters (QVariant logParams)
 Sets the output parameters for the log worker object. More...
 

Signals

void outputParametersUpdated (QVariant logParams)
 

Public Member Functions

 ZblLogWorker (QObject *parent=0)
 

Protected Member Functions

bool createLogFile ()
 
void closeLogFile ()
 
bool writeFileInformation (QFile &logFile, QString creationTime, QByteArray creationZone)
 
void outputTextMessage (const ZblLogMessage &msg)
 
void outputJsonMessage (const ZblLogMessage &msg)
 
QString formatTextMessage (const ZblLogMessage &msg)
 

Protected Attributes

ZblLogParams m_logParam
 Zuble logging output parameters. More...
 
bool m_outFileActive
 true if output file object is opened and accepting data, false otherwise. More...
 
QFile m_outputFile
 The log output file object. More...
 
QTextStream m_outputStream
 The log output stream object. More...
 
ZTableModelm_logBuffer
 Pointer to the log manager's log record histogram buffer. More...
 
quint64 m_nextRecordNumber
 A running counter to generate log record numbers. More...
 
QString m_appName
 Application name that will be written to log file. More...
 
QString m_hostName
 Name of the host executable application. More...
 
int m_hostVersionMajor
 Major version of the host executable application. More...
 
int m_hostVersionMinor
 Minor version of the host executable application. More...
 
int m_hostVersionPatch
 Patch version of the host executable application. More...
 
QString m_hostVersionBulid
 Build name of the host executable application. More...
 
QString m_logSource
 String that will be written to the "source" field of the log file. More...
 

Friends

class ZblLogManager
 

Detailed Description

This class provides a thread-safe log message back end for the Zuble log manager.

It should be created in the main thread and then moved to a background thread. This object serializes logging output by accepting log messages from all threads into a queued connection method. It discards log messages generated by it's own thread to avoid logging loops.

See also
Zbl::ZblLogManager

Definition at line 50 of file ZblLogWorker.h.

Constructor & Destructor Documentation

◆ ZblLogWorker()

Zbl::ZblLogWorker::ZblLogWorker ( QObject *  parent = 0)
explicit

Definition at line 52 of file ZblLogWorker.cpp.

Member Function Documentation

◆ closeLogFile()

void Zbl::ZblLogWorker::closeLogFile ( )
protected

Definition at line 183 of file ZblLogWorker.cpp.

Referenced by createLogFile(), outputLogMessage(), and setOutputParameters().

◆ createLogFile()

bool Zbl::ZblLogWorker::createLogFile ( )
protected

Definition at line 101 of file ZblLogWorker.cpp.

Referenced by setOutputParameters().

◆ formatTextMessage()

QString Zbl::ZblLogWorker::formatTextMessage ( const ZblLogMessage msg)
protected

Definition at line 334 of file ZblLogWorker.cpp.

Referenced by outputLogMessage(), and outputTextMessage().

◆ outputJsonMessage()

void Zbl::ZblLogWorker::outputJsonMessage ( const ZblLogMessage msg)
protected

Definition at line 367 of file ZblLogWorker.cpp.

Referenced by outputLogMessage().

◆ outputLogMessage

void Zbl::ZblLogWorker::outputLogMessage ( QVariant  message)
slot

Outputs a log message to the log histogram buffer and/or a file and/or stdout.

This slot should only be invoked with a Qt::QueuedConnection or Qt::BlockingQueuedConnection connection type to preserve log message serialization. Don't call this method directly.

Parameters
messageA variant containing a Zbl::ZblLogMessage object

Definition at line 241 of file ZblLogWorker.cpp.

◆ outputParametersUpdated

void Zbl::ZblLogWorker::outputParametersUpdated ( QVariant  logParams)
signal

◆ outputTextMessage()

void Zbl::ZblLogWorker::outputTextMessage ( const ZblLogMessage msg)
protected

Definition at line 329 of file ZblLogWorker.cpp.

Referenced by outputLogMessage().

◆ setOutputParameters

void Zbl::ZblLogWorker::setOutputParameters ( QVariant  logParams)
slot

Sets the output parameters for the log worker object.

This slot should only be invoked with a Qt::QueuedConnection connection type to preserve integrity of this object's state machine.

Parameters
logParamsA QVariant object containing a ZblLogParams object

Definition at line 298 of file ZblLogWorker.cpp.

◆ writeFileInformation()

bool Zbl::ZblLogWorker::writeFileInformation ( QFile &  logFile,
QString  creationTime,
QByteArray  creationZone 
)
protected

Definition at line 195 of file ZblLogWorker.cpp.

Referenced by createLogFile().

◆ zInit

bool Zbl::ZblLogWorker::zInit ( const QString &  logSource,
ZTableModel logBuffer 
)
slot

Initializes the ZblLogWorker object. This method should be called after the ZblLogWorker object has been moved to it's host thread. It should be called only once prior to calling any other methods on this object.

Parameters
logFileLocationOptional path to the directory in which Zuble will create log files. Pass an empty string to use the default location: data://logs
logBufferA pointer to the log histogram buffer to receive log record output
Returns
true if initialization successful, false if failed

Definition at line 71 of file ZblLogWorker.cpp.

Referenced by Zbl::ZblLogManager::zInit().

Friends And Related Function Documentation

◆ ZblLogManager

friend class ZblLogManager
friend

Definition at line 52 of file ZblLogWorker.h.

Member Data Documentation

◆ m_appName

QString Zbl::ZblLogWorker::m_appName
protected

Application name that will be written to log file.

Definition at line 165 of file ZblLogWorker.h.

Referenced by writeFileInformation(), and zInit().

◆ m_hostName

QString Zbl::ZblLogWorker::m_hostName
protected

Name of the host executable application.

Definition at line 171 of file ZblLogWorker.h.

Referenced by writeFileInformation(), and zInit().

◆ m_hostVersionBulid

QString Zbl::ZblLogWorker::m_hostVersionBulid
protected

Build name of the host executable application.

Definition at line 191 of file ZblLogWorker.h.

Referenced by writeFileInformation(), and zInit().

◆ m_hostVersionMajor

int Zbl::ZblLogWorker::m_hostVersionMajor
protected

Major version of the host executable application.

Definition at line 176 of file ZblLogWorker.h.

Referenced by writeFileInformation(), and zInit().

◆ m_hostVersionMinor

int Zbl::ZblLogWorker::m_hostVersionMinor
protected

Minor version of the host executable application.

Definition at line 181 of file ZblLogWorker.h.

Referenced by writeFileInformation(), and zInit().

◆ m_hostVersionPatch

int Zbl::ZblLogWorker::m_hostVersionPatch
protected

Patch version of the host executable application.

Definition at line 186 of file ZblLogWorker.h.

Referenced by writeFileInformation(), and zInit().

◆ m_logBuffer

ZTableModel* Zbl::ZblLogWorker::m_logBuffer
protected

Pointer to the log manager's log record histogram buffer.

Definition at line 151 of file ZblLogWorker.h.

Referenced by outputLogMessage(), and zInit().

◆ m_logParam

ZblLogParams Zbl::ZblLogWorker::m_logParam
protected

Zuble logging output parameters.

Definition at line 127 of file ZblLogWorker.h.

Referenced by createLogFile(), formatTextMessage(), outputLogMessage(), and setOutputParameters().

◆ m_logSource

QString Zbl::ZblLogWorker::m_logSource
protected

String that will be written to the "source" field of the log file.

Definition at line 196 of file ZblLogWorker.h.

Referenced by formatTextMessage(), outputJsonMessage(), outputLogMessage(), and zInit().

◆ m_nextRecordNumber

quint64 Zbl::ZblLogWorker::m_nextRecordNumber
protected

A running counter to generate log record numbers.

Log record numbers are not guaranteed to be unique or sequential once written to a log file but are highly likely to be.

Definition at line 159 of file ZblLogWorker.h.

Referenced by formatTextMessage(), outputJsonMessage(), and outputLogMessage().

◆ m_outFileActive

bool Zbl::ZblLogWorker::m_outFileActive
protected

true if output file object is opened and accepting data, false otherwise.

Definition at line 133 of file ZblLogWorker.h.

Referenced by closeLogFile(), createLogFile(), and outputLogMessage().

◆ m_outputFile

QFile Zbl::ZblLogWorker::m_outputFile
protected

The log output file object.

Definition at line 139 of file ZblLogWorker.h.

Referenced by closeLogFile(), createLogFile(), and outputJsonMessage().

◆ m_outputStream

QTextStream Zbl::ZblLogWorker::m_outputStream
protected

The log output stream object.

Definition at line 145 of file ZblLogWorker.h.

Referenced by closeLogFile(), createLogFile(), and outputTextMessage().


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