@aws-sdk/middleware-logger
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [3.1.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.0.0...v3.1.0) (2020-12-23) | ||
### Bug Fixes | ||
* log requestId, extendedRequestId, cfId in $metadata ([#1819](https://github.com/aws/aws-sdk-js-v3/issues/1819)) ([f2a47e8](https://github.com/aws/aws-sdk-js-v3/commit/f2a47e80965f96b86fa42038bf2711b922eee302)) | ||
### Features | ||
* **middleware-logger:** log clientName, commandName, input, output ([#1788](https://github.com/aws/aws-sdk-js-v3/issues/1788)) ([4f9e56f](https://github.com/aws/aws-sdk-js-v3/commit/4f9e56f1b7fd1cd9374b2577786e4ab0f6602aaa)) | ||
# [3.0.0](https://github.com/aws/aws-sdk-js-v3/compare/v1.0.0-rc.10...v3.0.0) (2020-12-15) | ||
@@ -8,0 +24,0 @@ |
@@ -5,4 +5,3 @@ "use strict"; | ||
const loggerMiddleware = () => (next, context) => async (args) => { | ||
var _a; | ||
const { logger } = context; | ||
const { clientName, commandName, inputFilterSensitiveLog, logger, outputFilterSensitiveLog } = context; | ||
const response = await next(args); | ||
@@ -12,11 +11,10 @@ if (!logger) { | ||
} | ||
const httpResponse = response.response; | ||
if (typeof logger.info === "function") { | ||
const { $metadata, ...outputWithoutMetadata } = response.output; | ||
logger.info({ | ||
metadata: { | ||
statusCode: httpResponse.statusCode, | ||
requestId: (_a = httpResponse.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : httpResponse.headers["x-amzn-request-id"], | ||
extendedRequestId: httpResponse.headers["x-amz-id-2"], | ||
cfId: httpResponse.headers["x-amz-cf-id"], | ||
}, | ||
clientName, | ||
commandName, | ||
input: inputFilterSensitiveLog(args.input), | ||
output: outputFilterSensitiveLog(outputWithoutMetadata), | ||
metadata: $metadata, | ||
}); | ||
@@ -39,2 +37,2 @@ } | ||
exports.getLoggerPlugin = getLoggerPlugin; | ||
//# sourceMappingURL=data:application/json;base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RXaXRob3V0TWV0YWRhdGEgfSA9IHJlc3BvbnNlLm91dHB1dDtcbiAgICBsb2dnZXIuaW5mbyh7XG4gICAgICBjbGllbnROYW1lLFxuICAgICAgY29tbWFuZE5hbWUsXG4gICAgICBpbnB1dDogaW5wdXRGaWx0ZXJTZW5zaXRpdmVMb2coYXJncy5pbnB1dCksXG4gICAgICBvdXRwdXQ6IG91dHB1dEZpbHRlclNlbnNpdGl2ZUxvZyhvdXRwdXRXaXRob3V0TWV0YWRhdGEpLFxuICAgICAgbWV0YWRhdGE6ICRtZXRhZGF0YSxcbiAgICB9KTtcbiAgfVxuXG4gIHJldHVybiByZXNwb25zZTtcbn07XG5cbmV4cG9ydCBjb25zdCBsb2dnZXJNaWRkbGV3YXJlT3B0aW9uczogSW5pdGlhbGl6ZUhhbmRsZXJPcHRpb25zICYgQWJzb2x1dGVMb2NhdGlvbiA9IHtcbiAgbmFtZTogXCJsb2dnZXJNaWRkbGV3YXJlXCIsXG4gIHRhZ3M6IFtcIkxPR0dFUlwiXSxcbiAgc3RlcDogXCJpbml0aWFsaXplXCIsXG59O1xuXG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgQHR5cGVzY3JpcHQtZXNsaW50L25vLXVudXNlZC12YXJzXG5leHBvcnQgY29uc3QgZ2V0TG9nZ2VyUGx1Z2luID0gKG9wdGlvbnM6IGFueSk6IFBsdWdnYWJsZTxhbnksIGFueT4gPT4gKHtcbiAgYXBwbHlUb1N0YWNrOiAoY2xpZW50U3RhY2spID0+IHtcbiAgICBjbGllbnRTdGFjay5hZGQobG9nZ2VyTWlkZGxld2FyZSgpLCBsb2dnZXJNaWRkbGV3YXJlT3B0aW9ucyk7XG4gIH0sXG59KTtcbiJdfQ== |
@@ -28,2 +28,11 @@ "use strict"; | ||
}; | ||
const mockOutput = { | ||
$metadata: { | ||
statusCode: 200, | ||
requestId: "requestId", | ||
attempts: 2, | ||
totalRetryDelay: 350, | ||
}, | ||
outputKey: "outputValue", | ||
}; | ||
const mockResponse = { | ||
@@ -38,5 +47,3 @@ response: { | ||
}, | ||
output: { | ||
outputKey: "outputValue", | ||
}, | ||
output: mockOutput, | ||
}; | ||
@@ -59,51 +66,69 @@ afterEach(() => { | ||
}); | ||
it("logs metadata if context.logger has info function", async () => { | ||
mockNext.mockResolvedValueOnce(mockResponse); | ||
const logger = { info: jest.fn() }; | ||
const context = { | ||
logger, | ||
}; | ||
const response = await loggerMiddleware_1.loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(mockResponse); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
metadata: { | ||
statusCode: mockResponse.response.statusCode, | ||
requestId: mockResponse.response.headers["x-amzn-requestid"], | ||
extendedRequestId: mockResponse.response.headers["x-amz-id-2"], | ||
cfId: mockResponse.response.headers["x-amz-cf-id"], | ||
}, | ||
describe("logs if context.logger has info function", () => { | ||
it("success case with clientName, commandName, input, metadata", async () => { | ||
mockNext.mockResolvedValueOnce(mockResponse); | ||
const logger = { info: jest.fn() }; | ||
const clientName = "mockClientName"; | ||
const commandName = "mockCommandName"; | ||
const mockInputLog = { inputKey: "inputKey", inputSensitiveKey: "SENSITIVE_VALUE" }; | ||
const inputFilterSensitiveLog = jest.fn().mockReturnValueOnce(mockInputLog); | ||
const mockOutputLog = { outputKey: "outputKey", outputSensitiveKey: "SENSITIVE_VALUE" }; | ||
const outputFilterSensitiveLog = jest.fn().mockReturnValueOnce(mockOutputLog); | ||
const context = { | ||
logger, | ||
clientName, | ||
commandName, | ||
inputFilterSensitiveLog, | ||
outputFilterSensitiveLog, | ||
}; | ||
const response = await loggerMiddleware_1.loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(mockResponse); | ||
expect(inputFilterSensitiveLog).toHaveBeenCalledTimes(1); | ||
expect(inputFilterSensitiveLog).toHaveBeenCalledWith(mockArgs.input); | ||
const { $metadata, ...outputWithoutMetadata } = mockOutput; | ||
expect(outputFilterSensitiveLog).toHaveBeenCalledTimes(1); | ||
expect(outputFilterSensitiveLog).toHaveBeenCalledWith(outputWithoutMetadata); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
clientName, | ||
commandName, | ||
input: mockInputLog, | ||
output: mockOutputLog, | ||
metadata: $metadata, | ||
}); | ||
}); | ||
}); | ||
it("logs header x-amzn-request-id as requestId if x-amzn-requestid is not present", async () => { | ||
const requestIdBackup = "requestIdBackup"; | ||
const customResponse = { | ||
...mockResponse, | ||
response: { | ||
...mockResponse.response, | ||
headers: { | ||
"x-amzn-request-id": requestIdBackup, | ||
it("header x-amzn-request-id as requestId if x-amzn-requestid is not present", async () => { | ||
const requestIdBackup = "requestIdBackup"; | ||
const customResponse = { | ||
...mockResponse, | ||
response: { | ||
...mockResponse.response, | ||
headers: { | ||
"x-amzn-request-id": requestIdBackup, | ||
}, | ||
}, | ||
}, | ||
}; | ||
mockNext.mockResolvedValueOnce(customResponse); | ||
const logger = { info: jest.fn() }; | ||
const context = { | ||
logger, | ||
}; | ||
const response = await loggerMiddleware_1.loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(customResponse); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
metadata: { | ||
statusCode: customResponse.response.statusCode, | ||
requestId: requestIdBackup, | ||
extendedRequestId: undefined, | ||
cfId: undefined, | ||
}, | ||
}; | ||
mockNext.mockResolvedValueOnce(customResponse); | ||
const logger = { info: jest.fn() }; | ||
const inputFilterSensitiveLog = jest.fn().mockImplementationOnce((input) => input); | ||
const outputFilterSensitiveLog = jest.fn().mockImplementationOnce((output) => output); | ||
const context = { | ||
logger, | ||
inputFilterSensitiveLog, | ||
outputFilterSensitiveLog, | ||
}; | ||
const response = await loggerMiddleware_1.loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(customResponse); | ||
const { $metadata, ...outputWithoutMetadata } = mockOutput; | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
input: mockArgs.input, | ||
output: outputWithoutMetadata, | ||
metadata: $metadata, | ||
}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyTWlkZGxld2FyZS5zcGVjLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvZ2dlck1pZGRsZXdhcmUuc3BlYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLHlEQUFnRztBQUVoRyxRQUFRLENBQUMsaUJBQWlCLEVBQUUsR0FBRyxFQUFFO0lBQy9CLE1BQU0sZUFBZSxHQUFHO1FBQ3RCLEdBQUcsRUFBRSxJQUFJLENBQUMsRUFBRSxFQUFFO0tBQ2YsQ0FBQztJQUVGLFNBQVMsQ0FBQyxHQUFHLEVBQUU7UUFDYixJQUFJLENBQUMsYUFBYSxFQUFFLENBQUM7SUFDdkIsQ0FBQyxDQUFDLENBQUM7SUFFSCxFQUFFLENBQUMsdUJBQXVCLEVBQUUsR0FBRyxFQUFFO1FBQy9CLGtDQUFlLENBQUMsRUFBRSxDQUFDLENBQUMsWUFBWSxDQUFFLGVBQXdELENBQUMsQ0FBQztRQUM1RixNQUFNLENBQUMsZUFBZSxDQUFDLEdBQUcsQ0FBQyxDQUFDLHFCQUFxQixDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3JELE1BQU0sQ0FBQyxlQUFlLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxD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ZFRpbWVzKDEpO1xuICAgICAgZXhwZWN0KGxvZ2dlci5pbmZvKS50b0hhdmVCZWVuQ2FsbGVkV2l0aCh7XG4gICAgICAgIGlucHV0OiBtb2NrQXJncy5pbnB1dCxcbiAgICAgICAgb3V0cHV0OiBvdXRwdXRXaXRob3V0TWV0YWRhdGEsXG4gICAgICAgIG1ldGFkYXRhOiAkbWV0YWRhdGEsXG4gICAgICB9KTtcbiAgICB9KTtcbiAgfSk7XG59KTtcbiJdfQ== |
@@ -1,9 +0,8 @@ | ||
import { __awaiter, __generator } from "tslib"; | ||
import { __awaiter, __generator, __rest } from "tslib"; | ||
export var loggerMiddleware = function () { return function (next, context) { return function (args) { return __awaiter(void 0, void 0, void 0, function () { | ||
var logger, response, httpResponse; | ||
var _a; | ||
var clientName, commandName, inputFilterSensitiveLog, logger, outputFilterSensitiveLog, response, _a, $metadata, outputWithoutMetadata; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
logger = context.logger; | ||
clientName = context.clientName, commandName = context.commandName, inputFilterSensitiveLog = context.inputFilterSensitiveLog, logger = context.logger, outputFilterSensitiveLog = context.outputFilterSensitiveLog; | ||
return [4 /*yield*/, next(args)]; | ||
@@ -15,11 +14,10 @@ case 1: | ||
} | ||
httpResponse = response.response; | ||
if (typeof logger.info === "function") { | ||
_a = response.output, $metadata = _a.$metadata, outputWithoutMetadata = __rest(_a, ["$metadata"]); | ||
logger.info({ | ||
metadata: { | ||
statusCode: httpResponse.statusCode, | ||
requestId: (_a = httpResponse.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : httpResponse.headers["x-amzn-request-id"], | ||
extendedRequestId: httpResponse.headers["x-amz-id-2"], | ||
cfId: httpResponse.headers["x-amz-cf-id"], | ||
}, | ||
clientName: clientName, | ||
commandName: commandName, | ||
input: inputFilterSensitiveLog(args.input), | ||
output: outputFilterSensitiveLog(outputWithoutMetadata), | ||
metadata: $metadata, | ||
}); | ||
@@ -42,2 +40,2 @@ }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@@ -1,2 +0,2 @@ | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import { __assign, __awaiter, __generator, __rest } from "tslib"; | ||
import { getLoggerPlugin, loggerMiddleware, loggerMiddlewareOptions } from "./loggerMiddleware"; | ||
@@ -27,2 +27,11 @@ describe("getLoggerPlugin", function () { | ||
}; | ||
var mockOutput = { | ||
$metadata: { | ||
statusCode: 200, | ||
requestId: "requestId", | ||
attempts: 2, | ||
totalRetryDelay: 350, | ||
}, | ||
outputKey: "outputValue", | ||
}; | ||
var mockResponse = { | ||
@@ -37,5 +46,3 @@ response: { | ||
}, | ||
output: { | ||
outputKey: "outputValue", | ||
}, | ||
output: mockOutput, | ||
}; | ||
@@ -76,63 +83,81 @@ afterEach(function () { | ||
}); }); | ||
it("logs metadata if context.logger has info function", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var logger, context, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
mockNext.mockResolvedValueOnce(mockResponse); | ||
logger = { info: jest.fn() }; | ||
context = { | ||
logger: logger, | ||
}; | ||
return [4 /*yield*/, loggerMiddleware()(mockNext, context)(mockArgs)]; | ||
case 1: | ||
response = _a.sent(); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(mockResponse); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
metadata: { | ||
statusCode: mockResponse.response.statusCode, | ||
requestId: mockResponse.response.headers["x-amzn-requestid"], | ||
extendedRequestId: mockResponse.response.headers["x-amz-id-2"], | ||
cfId: mockResponse.response.headers["x-amz-cf-id"], | ||
}, | ||
}); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it("logs header x-amzn-request-id as requestId if x-amzn-requestid is not present", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var requestIdBackup, customResponse, logger, context, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
requestIdBackup = "requestIdBackup"; | ||
customResponse = __assign(__assign({}, mockResponse), { response: __assign(__assign({}, mockResponse.response), { headers: { | ||
"x-amzn-request-id": requestIdBackup, | ||
} }) }); | ||
mockNext.mockResolvedValueOnce(customResponse); | ||
logger = { info: jest.fn() }; | ||
context = { | ||
logger: logger, | ||
}; | ||
return [4 /*yield*/, loggerMiddleware()(mockNext, context)(mockArgs)]; | ||
case 1: | ||
response = _a.sent(); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(customResponse); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
metadata: { | ||
statusCode: customResponse.response.statusCode, | ||
requestId: requestIdBackup, | ||
extendedRequestId: undefined, | ||
cfId: undefined, | ||
}, | ||
}); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
describe("logs if context.logger has info function", function () { | ||
it("success case with clientName, commandName, input, metadata", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var logger, clientName, commandName, mockInputLog, inputFilterSensitiveLog, mockOutputLog, outputFilterSensitiveLog, context, response, $metadata, outputWithoutMetadata; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
mockNext.mockResolvedValueOnce(mockResponse); | ||
logger = { info: jest.fn() }; | ||
clientName = "mockClientName"; | ||
commandName = "mockCommandName"; | ||
mockInputLog = { inputKey: "inputKey", inputSensitiveKey: "SENSITIVE_VALUE" }; | ||
inputFilterSensitiveLog = jest.fn().mockReturnValueOnce(mockInputLog); | ||
mockOutputLog = { outputKey: "outputKey", outputSensitiveKey: "SENSITIVE_VALUE" }; | ||
outputFilterSensitiveLog = jest.fn().mockReturnValueOnce(mockOutputLog); | ||
context = { | ||
logger: logger, | ||
clientName: clientName, | ||
commandName: commandName, | ||
inputFilterSensitiveLog: inputFilterSensitiveLog, | ||
outputFilterSensitiveLog: outputFilterSensitiveLog, | ||
}; | ||
return [4 /*yield*/, loggerMiddleware()(mockNext, context)(mockArgs)]; | ||
case 1: | ||
response = _a.sent(); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(mockResponse); | ||
expect(inputFilterSensitiveLog).toHaveBeenCalledTimes(1); | ||
expect(inputFilterSensitiveLog).toHaveBeenCalledWith(mockArgs.input); | ||
$metadata = mockOutput.$metadata, outputWithoutMetadata = __rest(mockOutput, ["$metadata"]); | ||
expect(outputFilterSensitiveLog).toHaveBeenCalledTimes(1); | ||
expect(outputFilterSensitiveLog).toHaveBeenCalledWith(outputWithoutMetadata); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
clientName: clientName, | ||
commandName: commandName, | ||
input: mockInputLog, | ||
output: mockOutputLog, | ||
metadata: $metadata, | ||
}); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it("header x-amzn-request-id as requestId if x-amzn-requestid is not present", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var requestIdBackup, customResponse, logger, inputFilterSensitiveLog, outputFilterSensitiveLog, context, response, $metadata, outputWithoutMetadata; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
requestIdBackup = "requestIdBackup"; | ||
customResponse = __assign(__assign({}, mockResponse), { response: __assign(__assign({}, mockResponse.response), { headers: { | ||
"x-amzn-request-id": requestIdBackup, | ||
} }) }); | ||
mockNext.mockResolvedValueOnce(customResponse); | ||
logger = { info: jest.fn() }; | ||
inputFilterSensitiveLog = jest.fn().mockImplementationOnce(function (input) { return input; }); | ||
outputFilterSensitiveLog = jest.fn().mockImplementationOnce(function (output) { return output; }); | ||
context = { | ||
logger: logger, | ||
inputFilterSensitiveLog: inputFilterSensitiveLog, | ||
outputFilterSensitiveLog: outputFilterSensitiveLog, | ||
}; | ||
return [4 /*yield*/, loggerMiddleware()(mockNext, context)(mockArgs)]; | ||
case 1: | ||
response = _a.sent(); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(customResponse); | ||
$metadata = mockOutput.$metadata, outputWithoutMetadata = __rest(mockOutput, ["$metadata"]); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
input: mockArgs.input, | ||
output: outputWithoutMetadata, | ||
metadata: $metadata, | ||
}); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyTWlkZGxld2FyZS5zcGVjLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvZ2dlck1pZGRsZXdhcmUuc3BlYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsT0FBTyxFQUFFLGVBQWUsRUFBRSxnQkFBZ0IsRUFBRSx1QkFBdUIsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRWhHLFFBQVEsQ0FBQyxpQkFBaUIsRUFBRTtJQUMxQixJQUFNLGVBQWUsR0FBRztRQUN0QixHQUFHLEVBQUUsSUFBSSxDQUFDLEVBQUUsRUFBRTtLQUNmLENBQUM7SUFFRixTQUFTLENBQUM7UUFDUixJQUFJLENBQUMsYUFBYSxFQUFFLENBQUM7SUFDdkIsQ0FBQyxDQUFDLENBQUM7SUFFSCxFQUFFLENBQUMsdUJBQXVCLEVBQUU7UUFDMUIsZUFBZSxDQUFDLEVBQUUsQ0FBQyxDQUFDLFlBQVksQ0FBRSxlQUF3RCxDQUFDLENBQUM7UUFDNUYsTUFBTSxDQUFDLGVBQWUsQ0FBQyxHQUFHLENBQUMsQ0FBQyxxQkFBcUIsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNyRCxNQUFNLENBQUMsZUFBZSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0F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gICAgIGV4cGVjdChsb2dnZXIuaW5mbykudG9IYXZlQmVlbkNhbGxlZFdpdGgoe1xuICAgICAgICBpbnB1dDogbW9ja0FyZ3MuaW5wdXQsXG4gICAgICAgIG91dHB1dDogb3V0cHV0V2l0aG91dE1ldGFkYXRhLFxuICAgICAgICBtZXRhZGF0YTogJG1ldGFkYXRhLFxuICAgICAgfSk7XG4gICAgfSk7XG4gIH0pO1xufSk7XG4iXX0= |
{ | ||
"name": "@aws-sdk/middleware-logger", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"scripts": { | ||
@@ -25,4 +25,4 @@ "prepublishOnly": "yarn build:cjs && yarn build:es", | ||
"devDependencies": { | ||
"@aws-sdk/protocol-http": "3.0.0", | ||
"@aws-sdk/types": "3.0.0", | ||
"@aws-sdk/protocol-http": "3.1.0", | ||
"@aws-sdk/types": "3.1.0", | ||
"@types/jest": "^26.0.4", | ||
@@ -29,0 +29,0 @@ "@types/node": "^10.0.0", |
# @aws-sdk/middleware-logger | ||
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/middleware-logger/rc.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-logger) | ||
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/middleware-logger/latest.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-logger) | ||
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/middleware-logger.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-logger) |
@@ -34,2 +34,12 @@ import { Logger, MiddlewareStack } from "@aws-sdk/types"; | ||
const mockOutput = { | ||
$metadata: { | ||
statusCode: 200, | ||
requestId: "requestId", | ||
attempts: 2, | ||
totalRetryDelay: 350, | ||
}, | ||
outputKey: "outputValue", | ||
}; | ||
const mockResponse = { | ||
@@ -44,5 +54,3 @@ response: { | ||
}, | ||
output: { | ||
outputKey: "outputValue", | ||
}, | ||
output: mockOutput, | ||
}; | ||
@@ -69,59 +77,79 @@ | ||
it("logs metadata if context.logger has info function", async () => { | ||
mockNext.mockResolvedValueOnce(mockResponse); | ||
const logger = ({ info: jest.fn() } as unknown) as Logger; | ||
describe("logs if context.logger has info function", () => { | ||
it("success case with clientName, commandName, input, metadata", async () => { | ||
mockNext.mockResolvedValueOnce(mockResponse); | ||
const context = { | ||
logger, | ||
}; | ||
const logger = ({ info: jest.fn() } as unknown) as Logger; | ||
const clientName = "mockClientName"; | ||
const commandName = "mockCommandName"; | ||
const response = await loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(mockResponse); | ||
const mockInputLog = { inputKey: "inputKey", inputSensitiveKey: "SENSITIVE_VALUE" }; | ||
const inputFilterSensitiveLog = jest.fn().mockReturnValueOnce(mockInputLog); | ||
const mockOutputLog = { outputKey: "outputKey", outputSensitiveKey: "SENSITIVE_VALUE" }; | ||
const outputFilterSensitiveLog = jest.fn().mockReturnValueOnce(mockOutputLog); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
const context = { | ||
logger, | ||
clientName, | ||
commandName, | ||
inputFilterSensitiveLog, | ||
outputFilterSensitiveLog, | ||
}; | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
metadata: { | ||
statusCode: mockResponse.response.statusCode, | ||
requestId: mockResponse.response.headers["x-amzn-requestid"], | ||
extendedRequestId: mockResponse.response.headers["x-amz-id-2"], | ||
cfId: mockResponse.response.headers["x-amz-cf-id"], | ||
}, | ||
const response = await loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(mockResponse); | ||
expect(inputFilterSensitiveLog).toHaveBeenCalledTimes(1); | ||
expect(inputFilterSensitiveLog).toHaveBeenCalledWith(mockArgs.input); | ||
const { $metadata, ...outputWithoutMetadata } = mockOutput; | ||
expect(outputFilterSensitiveLog).toHaveBeenCalledTimes(1); | ||
expect(outputFilterSensitiveLog).toHaveBeenCalledWith(outputWithoutMetadata); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
clientName, | ||
commandName, | ||
input: mockInputLog, | ||
output: mockOutputLog, | ||
metadata: $metadata, | ||
}); | ||
}); | ||
}); | ||
it("logs header x-amzn-request-id as requestId if x-amzn-requestid is not present", async () => { | ||
const requestIdBackup = "requestIdBackup"; | ||
const customResponse = { | ||
...mockResponse, | ||
response: { | ||
...mockResponse.response, | ||
headers: { | ||
"x-amzn-request-id": requestIdBackup, | ||
it("header x-amzn-request-id as requestId if x-amzn-requestid is not present", async () => { | ||
const requestIdBackup = "requestIdBackup"; | ||
const customResponse = { | ||
...mockResponse, | ||
response: { | ||
...mockResponse.response, | ||
headers: { | ||
"x-amzn-request-id": requestIdBackup, | ||
}, | ||
}, | ||
}, | ||
}; | ||
mockNext.mockResolvedValueOnce(customResponse); | ||
const logger = ({ info: jest.fn() } as unknown) as Logger; | ||
}; | ||
mockNext.mockResolvedValueOnce(customResponse); | ||
const logger = ({ info: jest.fn() } as unknown) as Logger; | ||
const inputFilterSensitiveLog = jest.fn().mockImplementationOnce((input) => input); | ||
const outputFilterSensitiveLog = jest.fn().mockImplementationOnce((output) => output); | ||
const context = { | ||
logger, | ||
}; | ||
const context = { | ||
logger, | ||
inputFilterSensitiveLog, | ||
outputFilterSensitiveLog, | ||
}; | ||
const response = await loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(customResponse); | ||
const response = await loggerMiddleware()(mockNext, context)(mockArgs); | ||
expect(mockNext).toHaveBeenCalledTimes(1); | ||
expect(response).toStrictEqual(customResponse); | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
metadata: { | ||
statusCode: customResponse.response.statusCode, | ||
requestId: requestIdBackup, | ||
extendedRequestId: undefined, | ||
cfId: undefined, | ||
}, | ||
const { $metadata, ...outputWithoutMetadata } = mockOutput; | ||
expect(logger.info).toHaveBeenCalledTimes(1); | ||
expect(logger.info).toHaveBeenCalledWith({ | ||
input: mockArgs.input, | ||
output: outputWithoutMetadata, | ||
metadata: $metadata, | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -19,3 +19,3 @@ import { HttpResponse } from "@aws-sdk/protocol-http"; | ||
): Promise<InitializeHandlerOutput<Output>> => { | ||
const { logger } = context; | ||
const { clientName, commandName, inputFilterSensitiveLog, logger, outputFilterSensitiveLog } = context; | ||
@@ -28,12 +28,10 @@ const response = await next(args); | ||
const httpResponse = response.response as HttpResponse; | ||
if (typeof logger.info === "function") { | ||
const { $metadata, ...outputWithoutMetadata } = response.output; | ||
logger.info({ | ||
metadata: { | ||
statusCode: httpResponse.statusCode, | ||
requestId: httpResponse.headers["x-amzn-requestid"] ?? httpResponse.headers["x-amzn-request-id"], | ||
extendedRequestId: httpResponse.headers["x-amz-id-2"], | ||
cfId: httpResponse.headers["x-amz-cf-id"], | ||
}, | ||
clientName, | ||
commandName, | ||
input: inputFilterSensitiveLog(args.input), | ||
output: outputFilterSensitiveLog(outputWithoutMetadata), | ||
metadata: $metadata, | ||
}); | ||
@@ -40,0 +38,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215950
576