diff options
author | 2021-03-15 02:10:37 +0300 | |
---|---|---|
committer | 2021-03-15 02:16:28 +0300 | |
commit | 7c46099b98bc23e373d78c3ff9739a6a26deb78a (patch) | |
tree | 630e5838814eba27f4e7b51ea5fbcfbdad17beee /backend/__init__.py | |
parent | Adds Logging Support (diff) |
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 <[email protected]>
Diffstat (limited to 'backend/__init__.py')
-rw-r--r-- | backend/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
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) |