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