diff --git a/main.py b/main.py index fa6e942..022d4b8 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,8 @@ import logging import random -import subprocess import re +import subprocess + import uvicorn @@ -24,4 +25,6 @@ def ip_addy(): port=8000, reload=True, use_colors=True, + log_level="info", + access_log=True, ) diff --git a/r3almX_backend/__init__.py b/r3almX_backend/__init__.py index d66b666..1d52af0 100644 --- a/r3almX_backend/__init__.py +++ b/r3almX_backend/__init__.py @@ -1,5 +1,6 @@ -from fastapi import FastAPI +from fastapi import FastAPI, Request, logger from fastapi.middleware.cors import CORSMiddleware +from loguru import logger from starlette.middleware.sessions import SessionMiddleware @@ -58,3 +59,18 @@ def add_models(self): r3almX = RealmX() + + +@r3almX.middleware("http") +async def log_requests(request: Request, call_next): + log_message = ( + f"IP Address: {request.client.host} | " + f"User Agent: {request.headers.get('User-Agent')} | " + f"Referrer: {request.headers.get('Referrer')} | " + f"Request Method: {request.method} | " + f"Request URL: {request.url}" + ) + logger.info(log_message) + + response = await call_next(request) + return response diff --git a/r3almX_backend/__pycache__/__init__.cpython-312.pyc b/r3almX_backend/__pycache__/__init__.cpython-312.pyc index d059a22..91df6fe 100644 Binary files a/r3almX_backend/__pycache__/__init__.cpython-312.pyc and b/r3almX_backend/__pycache__/__init__.cpython-312.pyc differ diff --git a/r3almX_backend/realtime_service/chat_service.py b/r3almX_backend/realtime_service/chat_service.py index 8a4ace3..bf8a450 100644 --- a/r3almX_backend/realtime_service/chat_service.py +++ b/r3almX_backend/realtime_service/chat_service.py @@ -74,8 +74,10 @@ def get_user_from_token(token: str, db) -> User: # 1711 south extension road -class MessageDigestion: +class DigestionBroker: def __init__(self): ... + + class RoomManager: """ Class to manage rooms and handle messaging between connected clients.