Skip to content

taschmidt/aws-lambda-log-wrapper

Repository files navigation

aws-lambda-log-wrapper

npm version

A tiny little wrapper around the amazing Lambda Log library for use as logging middleware in AWS SDK for JavaScript v3.

Installation

yarn add aws-lambda-log-wrapper

OR

npm i aws-lambda-log-wrapper

Usage

import { AwsLambdaLogWrapper } from 'aws-lambda-log-wrapper';
import { STSClient, GetCallerIdentityCommand } from '@aws-sdk/client-sts';
import { LambdaLog } from 'lambda-log';

const log = new LambdaLog();

new STSClient({ logger: new AwsLambdaLogWrapper(log) }).send(new GetCallerIdentityCommand({}))

Writes the following to the console:

{
  "_logLevel": "info",
  "msg": "AWS: Call STSClient.GetCallerIdentityCommand",
  "clientName":"STSClient",
  "commandName":"GetCallerIdentityCommand",
  "input": {},
  "output": {
    "UserId": "...",
    "Account": "...",
    "Arn": "arn:aws:sts::...:assumed-role/..."
  },
  "metadata": {
    "httpStatusCode": 200,
    "requestId": "25fe0f95-7975-443f-bcd9-65321461aa43",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "aws-sdk": true,
  "_tags": []
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published