#ifndef SYSTEM_LOG_MANAGER_H #define SYSTEM_LOG_MANAGER_H #include #include #include #include "Database.h" // ϵͳÈÕÖ¾¹ÜÀíÀà class SystemLogManager { public: // ÈÕÖ¾ÀàÐͶ¨Òå enum class LogType { Info, Error, Operation, Unknown }; // »ñÈ¡µ¥ÀýʵÀý static SystemLogManager& getInstance(); // ÉèÖÃÊý¾Ý¿âÁ¬½Ó void setDatabase(BL::Database* db); // ³õʼ»¯ÈÕÖ¾±í bool initializeLogTable(); // Ìí¼ÓÈÕÖ¾ bool log(LogType logType, const std::string& event); bool log(LogType logType, const std::string& event, const std::string& username); // »ñÈ¡ÈÕÖ¾ÄÚÈÝ std::vector> getLogs(int startPosition = -1, int count = -1); // »ñȡɸѡºóµÄÈÕÖ¾Êý¾Ý std::vector> getFilteredLogs( const std::string& logType, const std::string& username, const std::string& description, const std::string& startTime, const std::string& endTime, int pageNumber, int pageSize); // »ñÈ¡·ûºÏÌõ¼þµÄÈÕÖ¾×ÜÊý int getTotalLogCount( const std::string& logType, const std::string& username, const std::string& description, const std::string& startTime, const std::string& endTime); // ÇåÀí³¬¹ýÖ¸¶¨ÌìÊýµÄ¾ÉÈÕÖ¾ void cleanOldLogs(int daysToKeep = 30); // ת»»ÈÕÖ¾ÀàÐÍΪ×Ö·û´® static std::string logTypeToString(LogType logType); private: // ¹¹Ô캯ÊýºÍÎö¹¹º¯Êý SystemLogManager(); ~SystemLogManager(); // ½ûÖ¹¿½±´ºÍ¸³Öµ SystemLogManager(const SystemLogManager&) = delete; SystemLogManager& operator=(const SystemLogManager&) = delete; // Êý¾Ý¿âÁ¬½Ó BL::Database* m_pDB = nullptr; // Ḭ̈߳²È«Ëø static std::mutex m_mutex; }; #endif // SYSTEM_LOG_MANAGER_H