| | |
| | | class SystemLogManager { |
| | | public: |
| | | enum class LogType { |
| | | Info, // 信息日志 |
| | | Error, // 错误日志 |
| | | Operation // 操作日志 |
| | | Info, |
| | | Error, |
| | | Operation, |
| | | Unknown |
| | | }; |
| | | |
| | | // 获取单例实例 |
| | |
| | | // 设置数据库连接 |
| | | void setDatabase(std::unique_ptr<BL::Database>& db); |
| | | |
| | | // 初始化日志表 |
| | | bool initializeLogTable(); |
| | | |
| | | // 添加日志 |
| | | bool log(LogType logType, const std::string& event, const std::string& username = "SYSTEM"); |
| | | bool log(LogType logType, const std::string& event); |
| | | bool log(LogType logType, const std::string& event, const std::string& username); |
| | | |
| | | // 获取日志 |
| | | std::vector<std::vector<std::string>> SystemLogManager::getLogs(int startPosition = -1, int count = -1); |
| | | |
| | | // 初始化日志表 |
| | | bool initializeLogTable(); |
| | | // 获取筛选后的日志数据 |
| | | std::vector<std::vector<std::string>> 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); |
| | | |
| | | private: |
| | | // 构造函数(私有化) |