Files
qyyfw 78ff261b5a 初始提交: Qihu-AIFlow v2.0.1 完整项目
- 前端 React+TypeScript (源码+构建产物)
- 后端 Python FastAPI
- 数据库迁移 001-015
- Docker部署配置
- 微信ClawBot API频道绑定
- 项目文档 README.md
2026-07-02 14:40:46 +08:00

27 lines
998 B
Python

"""
AIFlow 日志中间件
- 记录用户操作日志
- 记录API调用日志(Token消耗)
- 操作日志和审计日志不可删除
"""
from fastapi import Request
from .log_service import LogService
async def log_operation(user_id: str, username: str, action: str, target: str = None,
target_id: str = None, detail: str = None, ip: str = None):
"""记录用户操作日志(异步安全)"""
try:
LogService.log_operation(user_id, username, action, target, target_id, detail, ip)
except Exception as e:
print(f"[LogError] 操作日志记录失败: {e}")
async def log_audit(admin_id: str, admin_name: str, action: str,
target_type: str = None, target_id: str = None, detail: str = None):
"""记录管理员审计日志"""
try:
LogService.log_audit(admin_id, admin_name, action, target_type, target_id, detail)
except Exception as e:
print(f"[AuditError] 审计日志记录失败: {e}")