Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add console log #49

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading