logs-redis-typings-fix

This commit is contained in:
2024-01-24 00:13:14 +03:00
parent 9b03e625f4
commit 8901ded662
7 changed files with 67 additions and 74 deletions

View File

@@ -10,6 +10,7 @@ import logging
logger = logging.getLogger("[services.auth] ")
logger.setLevel(logging.DEBUG)
async def check_auth(req) -> str | None:
token = req.headers.get("Authorization")
user_id = ""

View File

@@ -20,7 +20,6 @@ def _request_endpoint(query_name, body) -> dict:
ts2 = time.time()
logger.debug(f"{query_name} response in {ts1-ts2} secs: <{response.status_code}> {response.text[:32]}..")
if response.status_code == 200:
try:
r = response.json()

View File

@@ -1,6 +1,10 @@
import redis.asyncio as aredis
from settings import REDIS_URL
import logging
logger = logging.getLogger("[services.redis] ")
logger.setLevel(logging.DEBUG)
class RedisCache:
@@ -19,11 +23,13 @@ class RedisCache:
async def execute(self, command, *args, **kwargs):
if self._client:
try:
print("[redis] " + command + " " + " ".join(args))
logger.debug(command + " " + " ".join(args))
r = await self._client.execute_command(command, *args, **kwargs)
logger.debug(type(r))
logger.debug(r)
return r
except Exception as e:
print(f"[redis] error: {e}")
logger.error(e)
async def subscribe(self, *channels):
if self._client:
@@ -45,12 +51,6 @@ class RedisCache:
return
await self._client.publish(channel, data)
async def mget(self, key, *keys):
if self._client:
print(f"[redis] MGET {key} {keys}")
return await self._client.mget(key, *keys)
redis = RedisCache()
__all__ = ["redis"]