#ifndef LOGMANAGER_H #define LOGMANAGER_H #include #include #include #include #include class LogManager : public QObject { Q_OBJECT public: static LogManager &instance() { static LogManager instance; return instance; } // Standard logging void addEntry(const QString &entry); void addError(const QString &error); void addLine(); // Debug logging - only logs if debug mode enabled void debug(const QString &entry); // Set debug mode checker (called from Settings initialization) void setDebugChecker(std::function checker); // Set log-to-file checker (called from Settings initialization) void setLogToFileChecker(std::function checker); // Call this after connecting to entryAdded signal to replay buffered entries void flushBufferedEntries(); signals: void entryAdded(const QString &entry); private: LogManager() : m_debugChecker(nullptr), m_logToFileChecker(nullptr), m_logFile(nullptr), m_hasListeners(false) {} ~LogManager(); void writeToFile(const QString &entry); void emitOrBuffer(const QString &entry); std::function m_debugChecker; std::function m_logToFileChecker; QFile *m_logFile; QStringList m_bufferedEntries; bool m_hasListeners; Q_DISABLE_COPY(LogManager) }; #endif // LOGMANAGER_H