#ifndef SYSTEM_LOG_MANAGER_H #define SYSTEM_LOG_MANAGER_H #include #include #include #include #include "Database.h" class SystemLogManager { public: enum class LogType { Info, // ÐÅÏ¢ÈÕÖ¾ Error, // ´íÎóÈÕÖ¾ Operation // ²Ù×÷ÈÕÖ¾ }; // »ñÈ¡µ¥ÀýʵÀý static SystemLogManager& getInstance(); // ÉèÖÃÊý¾Ý¿âÁ¬½Ó void setDatabase(std::unique_ptr& db); // Ìí¼ÓÈÕÖ¾ bool log(LogType logType, const std::string& event, const std::string& username = "SYSTEM"); // »ñÈ¡ÈÕÖ¾ std::vector> SystemLogManager::getLogs(int startPosition = -1, int count = -1); // ³õʼ»¯ÈÕÖ¾±í bool initializeLogTable(); private: // ¹¹Ô캯Êý£¨Ë½Óл¯£© SystemLogManager(); // ½ûÖ¹¿½±´ºÍ¸³Öµ SystemLogManager(const SystemLogManager&) = delete; SystemLogManager& operator=(const SystemLogManager&) = delete; // ת»»ÈÕÖ¾ÀàÐÍΪ×Ö·û´® std::string logTypeToString(LogType logType) const; // Êý¾Ý¿âÁ¬½Ó std::unique_ptr* m_pDB; // µ¥ÀýʵÀý static std::unique_ptr m_instance; // Ḭ̈߳²È«Ëø static std::mutex m_mutex; }; #endif // SYSTEM_LOG_MANAGER_H