Skip to content

Commit

Permalink
Merge pull request #49 from daisybio/modules
Browse files Browse the repository at this point in the history
Add console log
  • Loading branch information
nictru authored Dec 20, 2024
2 parents 2519655 + 55d93be commit 965a436
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@
import app.config as config
import os
from connexion.resolver import RelativeResolver
import logging
import sys
from flask import request


# Get the application instance
connex_app = config.connex_app

# Configure logging to the console (stdout)
logging.basicConfig(
stream=sys.stdout, # Output to console
level=logging.INFO, # Logging level
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

@connex_app.app.before_request
def log_request():
logger.info(f"Incoming request: {request.method} {request.url}")
logger.info(f"Headers: {dict(request.headers)}")
logger.info(f"Body: {request.get_data(as_text=True)}")

# Read the swagger.yml file to configure the endpoints
swagger_file = os.path.join(os.path.dirname(__file__), "swagger.yml")
connex_app.add_api(swagger_file, resolver=RelativeResolver('app.controllers'))
Expand Down

0 comments on commit 965a436

Please sign in to comment.