78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
#ifndef IMS_AUDIT_LOGGER_HPP
|
|
#define IMS_AUDIT_LOGGER_HPP
|
|
|
|
#include "ims_types.hpp"
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace ims {
|
|
|
|
/// @brief 审计日志管理类。
|
|
///
|
|
/// 负责系统登录日志、操作日志、异常日志的记录与溯源查询。
|
|
class AuditLogger {
|
|
public:
|
|
AuditLogger();
|
|
~AuditLogger();
|
|
|
|
// ==================== 登录日志记录 (SRS-IMS_F-023) ====================
|
|
|
|
/**
|
|
* @brief 记录用户登录日志。
|
|
*
|
|
* @requirement(name="登录日志记录", id="SRS-IMS_F-023")
|
|
* 记录用户登录成功/失败的时间、IP 等信息。
|
|
*/
|
|
void logLogin(int64_t user_id,
|
|
const std::string& username,
|
|
bool success,
|
|
const std::string& ip_address);
|
|
|
|
// ==================== 操作日志记录 (SRS-IMS_F-024) ====================
|
|
|
|
/**
|
|
* @brief 记录关键操作日志。
|
|
*
|
|
* @requirement(name="操作日志记录", id="SRS-IMS_F-024")
|
|
* 记录用户对业务数据的关键操作(新增、修改、删除、审核等)。
|
|
*/
|
|
void logOperation(int64_t user_id,
|
|
const std::string& username,
|
|
const std::string& action,
|
|
const std::string& detail);
|
|
|
|
// ==================== 异常日志记录 (SRS-IMS_F-025) ====================
|
|
|
|
/**
|
|
* @brief 记录系统异常日志。
|
|
*
|
|
* @requirement(name="异常日志记录", id="SRS-IMS_F-025")
|
|
* 记录系统运行时发生的异常或错误信息。
|
|
*/
|
|
void logException(const std::string& action,
|
|
const std::string& detail);
|
|
|
|
// ==================== 日志溯源查询 (SRS-IMS_F-026) ====================
|
|
|
|
/**
|
|
* @brief 多条件查询日志,支持溯源。
|
|
*
|
|
* @requirement(name="日志溯源查询", id="SRS-IMS_F-026")
|
|
* 按日志类型、用户、时间范围、操作内容等多条件组合检索日志。
|
|
*/
|
|
std::vector<LogEntry> queryLogs(
|
|
LogType log_type,
|
|
int64_t user_id,
|
|
const std::string& keyword,
|
|
const std::chrono::system_clock::time_point& start_time,
|
|
const std::chrono::system_clock::time_point& end_time);
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> pImpl_;
|
|
};
|
|
|
|
} // namespace ims
|
|
|
|
#endif // IMS_AUDIT_LOGGER_HPP
|