Skip to content

Commit

Permalink
update log statement
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Jul 20, 2024
1 parent e9626a2 commit d1966e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions code/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import json
from aws_lambda_powertools.utilities.typing import LambdaContext
from util.server import app
from util.logging import configure_request_id
from util.logging import configure_request_id, get_logger
import traceback

def lambda_handler(event: dict, context: LambdaContext) -> dict:
request_id = event["requestContext"]["requestId"]
ctx = event["requestContext"]
configure_request_id(request_id) # Configure the logger with the request ID
logger = get_logger()
if "queryStringParameters" in event and event["queryStringParameters"] is not None:
full_path = f"{ctx['path']}?" + "&".join(
[f"{key}={value}" for key, value in event["queryStringParameters"].items()]
Expand All @@ -24,7 +25,7 @@ def lambda_handler(event: dict, context: LambdaContext) -> dict:
rval = app.resolve(event, context)
status_code = rval["statusCode"]
except Exception:
print("An error occured and bubbled up: ", traceback.format_exc(), flush=True)
logger.info(f"An error occured and bubbled up: {traceback.format_exc()}")
rval = {
"statusCode": 502,
"headers": {"Content-Type": "application/json"},
Expand Down

0 comments on commit d1966e1

Please sign in to comment.