Skip to content

Commit

Permalink
adding logging to test fragment data
Browse files Browse the repository at this point in the history
  • Loading branch information
brokoli777 committed Jul 27, 2024
1 parent 47bc7fc commit eb3c76d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/model/data/aws/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/model/data/memory/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}

Expand Down

0 comments on commit eb3c76d

Please sign in to comment.