diff --git a/chat/README.md b/chat/README.md index fd78e20..d6a0211 100644 --- a/chat/README.md +++ b/chat/README.md @@ -18,7 +18,7 @@ This only needs to be done once. ### Deploy a development stack -1. [Log into AWS](http://docs.rdc.library.northwestern.edu/2._Developer_Guides/Environment_and_Tools/AWS-Authentication/) using your `staging-admin` profile. +1. [Log into AWS](http://docs.rdc.library.northwestern.edu/2._Developer_Guides/Environment_and_Tools/AWS-Authentication/) using your `staging-superuser` profile. 2. Pick a unique stack name, e.g., `dc-api-chat-[YOUR_INITIALS]` 3. Create or synchronize the development stack ```bash diff --git a/chat/src/handlers/chat.py b/chat/src/handlers/chat.py index 98e0b1d..4250008 100644 --- a/chat/src/handlers/chat.py +++ b/chat/src/handlers/chat.py @@ -1,5 +1,6 @@ import secrets # noqa import boto3 +import json import logging import os from datetime import datetime @@ -65,7 +66,19 @@ def handler(event, context): config={"configurable": {"thread_id": config.ref}}, ) - print(response) + log_group = os.getenv('METRICS_LOG_GROUP') + log_stream = context.log_stream_name + if log_group and ensure_log_stream_exists(log_group, log_stream): + log_client = boto3.client('logs') + log_events = [ + { + 'timestamp': timestamp(), + 'message': json.dumps(response) + } + ] + log_client.put_log_events(logGroupName=log_group, logStreamName=log_stream, logEvents=log_events) + + return {"statusCode": 200} def reshape_response(response, type):