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
ZblLogAgent.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: ZblLogAgent.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 ZBLLOGAGENT_H
26 #define ZBLLOGAGENT_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 ZblLogAgent : public QObject
51 {
52  friend class ZblLogManager;
53 
54  Q_OBJECT
55 public:
56 
57 
58  explicit ZblLogAgent(QObject *parent = nullptr);
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 
129 
130 
131 #if 1
132 
137 
138 #endif
139 
144  QTextStream m_outputStream;
145 
146 #if 1
147 
153 
161 #endif
162 
167  QString m_appName;
168 
173  QString m_hostName;
174 
179 
183  QString m_logSource;
184 
189 
194 
199 
205 
206 
207 };
208 
209 } // Zbl
210 
211 #endif // ZBLLOGAGENT_H
The Zuble Log Manager is a singleton object that controls logging in Zuble applications.
Definition: ZblLogManager.h:70
void setOutputParameters(QVariant logParams)
Sets the output parameters for the log worker object.
This class provides a thread-safe log message back end for the Zuble log manager. ...
Definition: ZblLogAgent.h:50
QFile m_outputFile
The log output file object.
Definition: ZblLogAgent.h:136
void outputLogMessage(QVariant message)
Outputs a log message to the log histogram buffer and/or a file and/or stdout.
QString m_hostName
Name of the host executable application.
Definition: ZblLogAgent.h:173
void outputTextMessage(const ZblLogMessage &msg)
bool writeFileInformation(QFile &logFile, QString creationTime, QByteArray creationZone)
ZTableModel * m_logBuffer
Pointer to the log manager&#39;s log record histogram buffer.
Definition: ZblLogAgent.h:152
int m_hostVersionPatch
Patch version of the host executable application.
Definition: ZblLogAgent.h:198
void outputParametersUpdated(QVariant logParams)
void outputJsonMessage(const ZblLogMessage &msg)
ZblLogParams m_logParam
Zuble logging output parameters.
Definition: ZblLogAgent.h:127
Definition: ZAndGate.cpp:6
QString m_appName
Application name that will be written to log file.
Definition: ZblLogAgent.h:167
QTextStream m_outputStream
The log output stream object.
Definition: ZblLogAgent.h:144
ZblLogAgent(QObject *parent=nullptr)
Definition: ZblLogAgent.cpp:52
This two dimensional table model is used to store and manipulate data.
Definition: ZTableModel.h:96
quint64 m_nextRecordNumber
A running counter to generate log record numbers.
Definition: ZblLogAgent.h:160
bool zInit(const QString &logSource, ZTableModel *logBuffer)
Initializes the ZblLogAgent object. This method should be called after the ZblLogAgent object has bee...
Definition: ZblLogAgent.cpp:71
This class contains the Zuble logging parameters that control log output.
Definition: ZblLogParams.h:38
QString m_logSource
String that will be written to the "source" field of the log file.
Definition: ZblLogAgent.h:183
int m_hostVersionMinor
Minor version of the host executable application.
Definition: ZblLogAgent.h:193
bool m_outFileActive
true if output file object is opened and accepting data, false otherwise.
Definition: ZblLogAgent.h:204
QString m_hostVersionBulid
Build name of the host executable application.
Definition: ZblLogAgent.h:178
int m_hostVersionMajor
Major version of the host executable application.
Definition: ZblLogAgent.h:188
This class is used to transfer log messages between threads.
Definition: ZblLogMessage.h:38
QString formatTextMessage(const ZblLogMessage &msg)