增加接口日志输出

This commit is contained in:
mark.tian
2025-12-02 19:57:54 +08:00
parent 6cb2b9225f
commit addd75fbf9
10 changed files with 1029 additions and 21 deletions

View File

@@ -3,6 +3,9 @@ import asyncio
import uuid
from typing import Optional
from app.config import settings
from app.logger import get_logger
logger = get_logger("redis")
class RedisLock:
@@ -15,6 +18,8 @@ class RedisLock:
async def acquire(self) -> bool:
"""获取分布式锁"""
logger.debug(f"🔒 尝试获取Redis锁: {self.key}")
lua_script = """
if redis.call("GET", KEYS[1]) == false then
return redis.call("SETEX", KEYS[1], ARGV[1], ARGV[2])
@@ -32,6 +37,11 @@ class RedisLock:
)
self.acquired = bool(result)
if self.acquired:
logger.debug(f"✅ Redis锁获取成功: {self.key}")
else:
logger.debug(f"❌ Redis锁获取失败: {self.key}")
return self.acquired
async def release(self) -> bool: