#pragma once #include #include #include #include #include namespace Cevo { struct DebugLogItem { QDateTime time; QString group; QString text; }; // Equivalent of DebugLog.pas's TDebugLog: a thread-safe, capped, optionally // file-backed log. class DebugLog : public QObject { Q_OBJECT public: explicit DebugLog(QObject *parent = nullptr); void add(QString text, QString group = QString()); void writeToFile(QString text) const; QList items() const; int maxCount() const { return m_maxCount; } void setMaxCount(int value); QString fileName = QStringLiteral("DebugLog.txt"); bool writeToFileEnable = false; signals: void newItem(const DebugLogItem &item); private: mutable QMutex m_lock; QList m_items; int m_maxCount = 100; }; } // namespace Cevo