@lamware/powertools-logger
v2.0.1
Published
Lamware Middleware to utilize the official Logger powertools
Downloads
85
Readme
This Lamware Middleware utilizes the official Lambda TypeScript Powertools provided by AWS to:
- Set-up and memoize a root
Logger
instance - Automatically add Lambda Context to all logging (can be disabled)
- Provide a logging interface to all further middleware & the handler itself
Installation
This package is available via NPM:
yarn add @lamware/powertools-logger
# or
npm install @lamware/powertools-logger
Usage
import { powertoolsLogger } from '@lamware/powertools-logger';
import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
import { lamware } from '@lamware/core';
const { handler } = lamware<APIGatewayProxyHandlerV2<any>>()
.use(powertoolsLogger({
// Options are pass-through to the Logger instance.
serviceName: 'my-api',
}))
.execute(async ({ state, logger }) => {
logger.debug('Hello world!');
return { statusCode: 200 };
});
export { handler };