1 | import { __awaiter, __generator, __rest } from "tslib";
|
2 | export var loggerMiddleware = function () {
|
3 | return function (next, context) {
|
4 | return function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
5 | var clientName, commandName, inputFilterSensitiveLog, logger, outputFilterSensitiveLog, response, _a, $metadata, outputWithoutMetadata;
|
6 | return __generator(this, function (_b) {
|
7 | switch (_b.label) {
|
8 | case 0:
|
9 | clientName = context.clientName, commandName = context.commandName, inputFilterSensitiveLog = context.inputFilterSensitiveLog, logger = context.logger, outputFilterSensitiveLog = context.outputFilterSensitiveLog;
|
10 | return [4, next(args)];
|
11 | case 1:
|
12 | response = _b.sent();
|
13 | if (!logger) {
|
14 | return [2, response];
|
15 | }
|
16 | if (typeof logger.info === "function") {
|
17 | _a = response.output, $metadata = _a.$metadata, outputWithoutMetadata = __rest(_a, ["$metadata"]);
|
18 | logger.info({
|
19 | clientName: clientName,
|
20 | commandName: commandName,
|
21 | input: inputFilterSensitiveLog(args.input),
|
22 | output: outputFilterSensitiveLog(outputWithoutMetadata),
|
23 | metadata: $metadata,
|
24 | });
|
25 | }
|
26 | return [2, response];
|
27 | }
|
28 | });
|
29 | }); };
|
30 | };
|
31 | };
|
32 | export var loggerMiddlewareOptions = {
|
33 | name: "loggerMiddleware",
|
34 | tags: ["LOGGER"],
|
35 | step: "initialize",
|
36 | override: true,
|
37 | };
|
38 | export var getLoggerPlugin = function (options) { return ({
|
39 | applyToStack: function (clientStack) {
|
40 | clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
|
41 | },
|
42 | }); };
|