From 7c46099b98bc23e373d78c3ff9739a6a26deb78a Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Mon, 15 Mar 2021 02:10:37 +0300 Subject: Adds Logging To Helpers Adds logging to the CORS setup, user, and discord helpers. Log statements have been setup in a way to maximize information for local development and prod debugging, while minimizing average load on the prod version. Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> --- backend/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'backend/__init__.py') diff --git a/backend/__init__.py b/backend/__init__.py index f8b0afe..b5360ef 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -8,12 +8,15 @@ from starlette.middleware.authentication import AuthenticationMiddleware from starlette.middleware.cors import CORSMiddleware from backend import constants -from backend import logs # This has to be imported before other logging statements +from backend import logs # This has to be imported before logging statements are used from backend.authentication import JWTAuthenticationBackend from backend.middleware import DatabaseMiddleware, ProtectedDocsMiddleware from backend.route_manager import create_route_map from backend.validation import api +logger = logging.getLogger(__name__) + +# Setup CORS Origins ORIGINS = [ r"(https://[^.?#]*--pydis-forms\.netlify\.app)", # Netlify Previews r"(https?://[^.?#]*.forms-frontend.pages.dev)", # Cloudflare Previews @@ -21,6 +24,7 @@ ORIGINS = [ if not constants.PRODUCTION: # Allow all hosts on non-production deployments + logger.info("Allowing all CORS origins.") ORIGINS.append(r"(.*)") ALLOW_ORIGIN_REGEX = "|".join(ORIGINS) -- cgit v1.2.3