From 542d47301bdfd0831e98dd443b6f4808010b30d0 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 8 Jan 2021 21:29:32 +1000 Subject: [PATCH] fix: change logging to include a log key --- src/index.js | 9 ++++++++- src/transport.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 5cd1063a..2b00629f 100644 --- a/src/index.js +++ b/src/index.js @@ -31,7 +31,14 @@ function proxy ({ log, respondWithErrors }) { - log.debug('Calling proxy', { event, context, resolutionMode, eventSource }) + log.debug('SERVERLESS_EXPRESS:PROXY', { + event, + context, + resolutionMode, + eventSource, + binaryMimeTypes, + respondWithErrors + }) setCurrentLambdaInvoke({ event, context }) return new Promise((resolve, reject) => { const promise = { diff --git a/src/transport.js b/src/transport.js index a8dcfc74..c22edb0a 100644 --- a/src/transport.js +++ b/src/transport.js @@ -19,13 +19,16 @@ function forwardResponse ({ eventResponseMapperFn, log }) { - log.debug('Forwarding response from application to API Gateway... HTTP response:', { headers: response.headers, statusCode: response.statusCode }) + log.debug('SERVERLESS_EXPRESS:FORWARD_RESPONSE:HTTP_RESPONSE', { + headers: response.headers, + statusCode: response.statusCode + }) const statusCode = response.statusCode const headers = Response.headers(response) const contentType = getContentType({ contentTypeHeader: headers['content-type'] }) - log.debug('contentType', { contentType }) + log.debug('SERVERLESS_EXPRESS:FORWARD_RESPONSE:CONTENT_TYPE', { contentType }) const isBase64Encoded = isContentTypeBinaryMimeType({ contentType, binaryMimeTypes @@ -38,7 +41,7 @@ function forwardResponse ({ isBase64Encoded }) - log.debug('Forwarding response from application to API Gateway... API Gateway response:', { successResponse }) + log.debug('SERVERLESS_EXPRESS:FORWARD_RESPONSE:API_GATEWAY_RESPONSE', { successResponse }) resolver.succeed({ response: successResponse }) @@ -51,7 +54,7 @@ function forwardLibraryErrorResponseToApiGateway ({ respondWithErrors, eventResponseMapperFn }) { - log.error('serverless-express error: ', error) + log.error('SERVERLESS_EXPRESS:FORWARD_LIBRARY_ERROR_RESPONSE_TO_API_GATEWAY:ERROR', error) const body = respondWithErrors ? error.stack : '' const errorResponse = eventResponseMapperFn({ @@ -77,7 +80,7 @@ async function forwardRequestToNodeServer ({ }) { const eventResponseMapperFn = eventFns.response const requestValues = eventFns.getRequestValues({ event }) - log.debug('Forwarding request to application...', { requestValues }) + log.debug('SERVERLESS_EXPRESS:REQUEST_VALUES', { requestValues }) const response = await framework.sendRequest({ app, requestValues }) forwardResponse({ binaryMimeTypes,