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
ZblLogWorker.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2015 Bob Dinitto
4  *
5  * Filename: ZblLogWorker.h
6  * Created on: 11/2/2015
7  * Author: Bob Dinitto
8  *
9  * Zuble is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #ifndef ZBLLOGWORKER_H
26 #define ZBLLOGWORKER_H
27 
28 #include <QObject>
29 #include <QFile>
30 #include <QTextStream>
31 #include <QVariantMap>
32 #include "ZTableModel.h"
33 #include "ZblLogParams.h"
34 
35 namespace Zbl {
36 
37 class ZblLogMessage;
38 
50 class ZblLogWorker : public QObject
51 {
52  friend class ZblLogManager;
53 
54  Q_OBJECT
55 public:
56 
57 
58  explicit ZblLogWorker(QObject *parent = 0);
59 
60 signals:
61 
62  void outputParametersUpdated(QVariant logParams);
63 
64 public slots:
65 
79  bool zInit(const QString& logSource,
80  ZTableModel* logBuffer);
81 
93  void outputLogMessage(QVariant message);
94 
103  void setOutputParameters(QVariant logParams);
104 
105 protected:
106 
107  bool createLogFile();
108 
109  void closeLogFile();
110 
112  QFile& logFile,
113  QString creationTime,
114  QByteArray creationZone);
115 
116  void outputTextMessage(const ZblLogMessage& msg);
117 
118  void outputJsonMessage(const ZblLogMessage& msg);
119 
120  QString formatTextMessage(const ZblLogMessage& msg);
121 
122 
128 
134 
140 
145  QTextStream m_outputStream;
146 
152 
160 
165  QString m_appName;
166 
171  QString m_hostName;
172 
177 
182 
187 
192 
196  QString m_logSource;
197 
198 };
199 
200 } // Zbl
201 
202 #endif // ZBLLOGWORKER_H
The Zuble Log Manager is a singleton object that controls logging in Zuble applications.
Definition: ZblLogManager.h:70
QString m_logSource
String that will be written to the "source" field of the log file.
Definition: ZblLogWorker.h:196
QString m_hostVersionBulid
Build name of the host executable application.
Definition: ZblLogWorker.h:191
quint64 m_nextRecordNumber
A running counter to generate log record numbers.
Definition: ZblLogWorker.h:159
QString m_hostName
Name of the host executable application.
Definition: ZblLogWorker.h:171
ZTableModel * m_logBuffer
Pointer to the log manager&#39;s log record histogram buffer.
Definition: ZblLogWorker.h:151
int m_hostVersionMinor
Minor version of the host executable application.
Definition: ZblLogWorker.h:181
QString formatTextMessage(const ZblLogMessage &msg)
This class provides a thread-safe log message back end for the Zuble log manager. ...
Definition: ZblLogWorker.h:50
int m_hostVersionMajor
Major version of the host executable application.
Definition: ZblLogWorker.h:176
void outputJsonMessage(const ZblLogMessage &msg)
void outputParametersUpdated(QVariant logParams)
ZblLogParams m_logParam
Zuble logging output parameters.
Definition: ZblLogWorker.h:127
bool writeFileInformation(QFile &logFile, QString creationTime, QByteArray creationZone)
QString m_appName
Application name that will be written to log file.
Definition: ZblLogWorker.h:165
Definition: ZAndGate.cpp:6
QTextStream m_outputStream
The log output stream object.
Definition: ZblLogWorker.h:145
void outputLogMessage(QVariant message)
Outputs a log message to the log histogram buffer and/or a file and/or stdout.
bool m_outFileActive
true if output file object is opened and accepting data, false otherwise.
Definition: ZblLogWorker.h:133
This two dimensional table model is used to store and manipulate data.
Definition: ZTableModel.h:96
void outputTextMessage(const ZblLogMessage &msg)
This class contains the Zuble logging parameters that control log output.
Definition: ZblLogParams.h:38
ZblLogWorker(QObject *parent=0)
bool zInit(const QString &logSource, ZTableModel *logBuffer)
Initializes the ZblLogWorker object. This method should be called after the ZblLogWorker object has b...
QFile m_outputFile
The log output file object.
Definition: ZblLogWorker.h:139
int m_hostVersionPatch
Patch version of the host executable application.
Definition: ZblLogWorker.h:186
void setOutputParameters(QVariant logParams)
Sets the output parameters for the log worker object.
This class is used to transfer log messages between threads.
Definition: ZblLogMessage.h:38