日志与配置精简

1. 邮件相关正常流程日志降为 DEBUG(发送成功、验证码已发送、绑定/解绑成功、找回密码请求未发送等),失败仍保留 ERROR
2. LOG_LEVEL 未配置时跟随 DEBUG 自动选择(DEBUG=true 输出 DEBUG,否则 INFO)
3. 删除未使用的 LOG_BACKUP_COUNT 配置
4. .env.example 补充日志级别说明
This commit is contained in:
canglan committed 2026-09-29 20:53:34 +08:00
1 parent 05790c1882
commit 9a19add6c1
4 files changed
+12 -11

No files matched your search

+7 -7
View File
@@ -235,7 +235,7 @@ class AuthService:
user = await UserModel.get_by_username(username)
if not user or user.get("user_type") != "admin":
logger.info(f"找回密码请求未发送(账号不存在/非管理员): {username}, IP={ip}")
logger.debug(f"找回密码请求未发送(账号不存在/非管理员): {username}, IP={ip}")
return generic_success
# 绑定邮箱仅在找回密码功能中查询
@@ -245,7 +245,7 @@ class AuthService:
logger.error(f"读取绑定邮箱失败(数据库可能待升级): {e}")
return {"success": False, "message": "数据库待升级,找回密码功能暂不可用"}
if not bound_email:
logger.info(f"找回密码请求未发送(未绑定邮箱): {username}, IP={ip}")
logger.debug(f"找回密码请求未发送(未绑定邮箱): {username}, IP={ip}")
return generic_success
# 生成一次性令牌,并作废该用户此前的令牌
@@ -282,7 +282,7 @@ class AuthService:
logger.error(f"密码重置邮件发送失败: {username} - {message_text}")
return {"success": False, "message": "重置邮件发送失败,请稍后重试或联系系统管理员"}
logger.info(f"已向用户[{username}]的绑定邮箱发送密码重置链接, IP={ip}")
logger.debug(f"已向用户[{username}]的绑定邮箱发送密码重置链接, IP={ip}")
return generic_success
@staticmethod
@@ -327,7 +327,7 @@ class AuthService:
await RedisClient.delete(f"pwd_reset:{token}")
await RedisClient.delete(f"pwd_reset_user:{user_id}")
await RedisClient.delete_user_token(user_id)
logger.info(f"用户[{user_id}] 通过邮箱重置密码成功")
logger.debug(f"用户[{user_id}] 通过邮箱重置密码成功")
return {"success": True, "message": "密码重置成功,请使用新密码登录"}
@staticmethod
@@ -398,7 +398,7 @@ class AuthService:
logger.error(f"邮箱验证码发送失败: 用户[{user_id}] -> {normalized_email} - {message}")
return {"success": False, "message": "验证码发送失败,请检查邮箱地址或稍后重试"}
logger.info(f"用户[{user_id}] 邮箱绑定验证码已发送至 {normalized_email}")
logger.debug(f"用户[{user_id}] 邮箱绑定验证码已发送至 {normalized_email}")
return {
"success": True,
"message": f"验证码已发送至 {normalized_email},{settings.EMAIL_CODE_EXPIRE_MINUTES} 分钟内有效"
@@ -442,7 +442,7 @@ class AuthService:
return {"success": False, "message": "邮箱绑定失败"}
await RedisClient.delete(f"email_bind_code:{user_id}")
logger.info(f"用户[{user_id}] 邮箱绑定成功: {normalized_email}")
logger.debug(f"用户[{user_id}] 邮箱绑定成功: {normalized_email}")
return {"success": True, "message": "邮箱绑定成功", "email": normalized_email}
@staticmethod
@@ -461,7 +461,7 @@ class AuthService:
if not updated:
return {"success": False, "message": "解除绑定失败"}
logger.info(f"用户[{user_id}] 已解除邮箱绑定")
logger.debug(f"用户[{user_id}] 已解除邮箱绑定")
return {"success": True, "message": "邮箱已解除绑定", "email": None}
@staticmethod