diff --git a/src/handlers/CreateEntity/function.ts b/src/handlers/CreateEntity/function.ts index 15c81fd..fcee44f 100644 --- a/src/handlers/CreateEntity/function.ts +++ b/src/handlers/CreateEntity/function.ts @@ -55,11 +55,12 @@ export async function putEntity(entity: Entity): Promise { try { const command = new PutItemCommand(params) output = await DDB_CLIENT.send(command) - LOGGER.info('PutItemCommand succeeded', { output }) + LOGGER.debug('PutItemCommand succeeded', { output }) } catch (error) { - LOGGER.error('PutItemCommand failed', { - error: (error).name, - message: error + LOGGER.error({ + name: (error).name, + message: (error).message, + error: error, }) throw error } @@ -69,7 +70,7 @@ export async function putEntity(entity: Entity): Promise { export async function handler (event: APIGatewayProxyEvent, _: Context): Promise { - LOGGER.info('Received event', { event }) + LOGGER.debug('Received event', { event }) const entity: Entity = JSON.parse(event.body || '{}') // Already validated body at Gateway @@ -80,6 +81,7 @@ export async function handler (event: APIGatewayProxyEvent, _: Context): Promise statusCode = 201 body = JSON.stringify({'request_id': output.$metadata.requestId}) } catch (error) { + LOGGER.error("Operation failed", { event }) const fault = (error).$fault switch (fault) { case 'client': diff --git a/src/handlers/DeleteEntity/function.ts b/src/handlers/DeleteEntity/function.ts index 6036f69..4a3ad24 100644 --- a/src/handlers/DeleteEntity/function.ts +++ b/src/handlers/DeleteEntity/function.ts @@ -38,12 +38,13 @@ export async function deleteEntity( try { const command = new DeleteItemCommand(params) output = await DDB_CLIENT.send(command) - LOGGER.info('DeleteItemCommand succeeded', { output }) + LOGGER.debug('DeleteItemCommand succeeded', { output }) } catch (error) { - LOGGER.error('DeleteItemCommand failed', { - error: (error).name, - message: error - }) + LOGGER.error({ + error: error, + name: (error).name, + message: (error).message, + }) throw error } @@ -52,7 +53,7 @@ export async function deleteEntity( export async function handler (event: APIGatewayProxyEvent, _: Context): Promise { - LOGGER.info('Received event', { event }) + LOGGER.debug('Received event', { event }) const namespace = event.pathParameters?.namespace as string const kind = event.pathParameters?.kind as string @@ -69,6 +70,7 @@ export async function handler (event: APIGatewayProxyEvent, _: Context): Promise statusCode = 200 body = JSON.stringify(entity) } catch (error) { + LOGGER.error("Operation failed", { event }) const fault = (error).$fault switch (fault) { case 'client': diff --git a/src/handlers/GetEntity/function.ts b/src/handlers/GetEntity/function.ts index e804480..30f9966 100644 --- a/src/handlers/GetEntity/function.ts +++ b/src/handlers/GetEntity/function.ts @@ -44,12 +44,13 @@ export async function getEntity( try { const command = new GetItemCommand(params) output = await DDB_CLIENT.send(command) - LOGGER.info('GetItemCommand succeeded', { output }) + LOGGER.debug('GetItemCommand succeeded', { output }) } catch (error) { - LOGGER.error('GetItemCommand failed', { - error: (error).name, - message: error - }) + LOGGER.error({ + error: error, + name: (error).name, + message: (error).message, + }) throw error } @@ -64,7 +65,7 @@ export async function getEntity( export async function handler (event: APIGatewayProxyEvent, _: Context): Promise { - LOGGER.info('Received event', { event }) + LOGGER.debug('Received event', { event }) const namespace = event.pathParameters?.namespace as string const kind = event.pathParameters?.kind as string @@ -81,6 +82,7 @@ export async function handler (event: APIGatewayProxyEvent, _: Context): Promise statusCode = 200 body = JSON.stringify(entity) } catch (error) { + LOGGER.error("Operation failed", { event }) const fault = (error).$fault switch (fault) { case 'client':