less-logs
This commit is contained in:
parent
5bcef53138
commit
8b23ece194
|
@ -5,6 +5,10 @@ from settings import AUTH_URL
|
|||
from services.db import local_session
|
||||
from orm.author import Author
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("\t[services.auth]\t")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
async def check_auth(req) -> str | None:
|
||||
token = req.headers.get("Authorization")
|
||||
|
|
|
@ -4,6 +4,10 @@ import redis.asyncio as aredis
|
|||
import asyncio
|
||||
from settings import REDIS_URL
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("\t[services.redis]\t")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
class RedisCache:
|
||||
def __init__(self, uri=REDIS_URL):
|
||||
|
@ -21,11 +25,11 @@ 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)
|
||||
return r
|
||||
except Exception as e:
|
||||
print(f"[redis] error: {e}")
|
||||
logger.error(f"{e}")
|
||||
return None
|
||||
|
||||
async def subscribe(self, *channels):
|
||||
|
@ -56,11 +60,11 @@ class RedisCache:
|
|||
while True:
|
||||
message = await pubsub.get_message()
|
||||
if message and isinstance(message["data"], (str, bytes, bytearray)):
|
||||
print(f"[services.rediscache] msg: {message}")
|
||||
logger.debug("pubsub got msg")
|
||||
try:
|
||||
yield json.loads(message["data"]), message.get("channel")
|
||||
except Exception as e:
|
||||
print(f"[servoces.rediscache] Error: {e}")
|
||||
logger.error(f"{e}")
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user