From eb3c76df300d7afa20941e5be30449a4aa6f5392 Mon Sep 17 00:00:00 2001 From: Bregwin Jogi Date: Fri, 26 Jul 2024 21:11:04 -0400 Subject: [PATCH] adding logging to test fragment data --- src/model/data/aws/index.js | 4 ++++ src/model/data/memory/index.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/model/data/aws/index.js b/src/model/data/aws/index.js index f1245ca..799fa4b 100644 --- a/src/model/data/aws/index.js +++ b/src/model/data/aws/index.js @@ -4,6 +4,8 @@ // services (S3, DynamoDB); otherwise, we'll use an in-memory db. module.exports = process.env.AWS_REGION ? require('./aws') : require('./memory'); +logger.info(`Using ${process.env.AWS_REGION ? 'AWS' : 'in-memory'} backend for data`); + const logger = require('../../logger'); const s3Client = require('./s3Client'); const { PutObjectCommand, GetObjectCommand, DeleteObjectCommand } = require('@aws-sdk/client-s3'); @@ -41,8 +43,10 @@ async function writeFragmentData(ownerId, id, data) { const command = new PutObjectCommand(params); try { + logger.info({ params }, 'S3- Attempting to upload fragment data to S3'); // Use our client to send the command await s3Client.send(command); + logger.info({ Bucket: params.Bucket, Key: params.Key }, 'Successfully uploaded fragment data to S3'); } catch (err) { // If anything goes wrong, log enough info that we can debug const { Bucket, Key } = params; diff --git a/src/model/data/memory/index.js b/src/model/data/memory/index.js index aa600fe..b45c7ce 100644 --- a/src/model/data/memory/index.js +++ b/src/model/data/memory/index.js @@ -1,3 +1,4 @@ +const logger = require('../../../logger'); const MemoryDB = require('./memory-db'); // Create two in-memory databases: one for fragment metadata and the other for raw data @@ -16,6 +17,7 @@ function readFragment(ownerId, id) { // Write a fragment's data buffer to memory db. Returns a Promise function writeFragmentData(ownerId, id, buffer) { + logger.info(`MEMORYDB - Writing fragment data to memory db for fragment ${id}`); return data.put(ownerId, id, buffer); }