This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
modern-linbo-gui/headers/backend/linbologger.h

48 lines
869 B
C++

#ifndef LINBOLOGGER_H
#define LINBOLOGGER_H
#include <QObject>
#include <QtDebug>
#include <QDateTime>
class LinboLogger : public QObject
{
Q_OBJECT
Q_PROPERTY(LinboLog latestLog READ getLatestLog NOTIFY latestLogChanged)
public:
friend class LinboBackend;
enum LinboLogType {
UnknownLogType = -1,
StdOut,
StdErr,
LinboGuiInfo,
LinboGuiError
};
typedef struct {
QString message;
LinboLogType type;
QDateTime time;
} LinboLog;
const LinboLog& getLatestLog();
QString logTypeToString(LinboLogType logType);
private:
explicit LinboLogger(QObject *parent = nullptr);
void log(QString logText, LinboLogType logType);
QList<LinboLog> logHistory;
signals:
void latestLogChanged(const LinboLogger::LinboLog& latestLog);
};
#endif // LINBOLOGGER_H