/**************************************************************************** ** Modern Linbo GUI ** Copyright (C) 2020 Dorian Zedler ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU Affero General Public License as published ** by the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Affero General Public License for more details. ** ** You should have received a copy of the GNU Affero General Public License ** along with this program. If not, see . ****************************************************************************/ #ifndef LINBOLOGGER_H #define LINBOLOGGER_H #include #include #include #include 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(); static QString logTypeToString(LinboLogType logType); private: explicit LinboLogger(QString logFilePath, QObject *parent = nullptr); void log(QString logText, LinboLogType logType); bool writeToLogFile(QString text); QString logFilePath; QList logHistory; signals: void latestLogChanged(const LinboLogger::LinboLog& latestLog); }; #endif // LINBOLOGGER_H