• A middy middleware that helps emitting CloudWatch EMF metrics in your logs.

    Using this middleware on your handler function will automatically add context information to logs, as well as optionally log the event and clear attributes set during the invocation.

    Parameters

    • target: Logger | Logger[]

      The Logger instance(s) to use for logging

    • Optional options: HandlerOptions

      (optional) Options for the middleware

    Returns MiddlewareLikeObj

    • The middy middleware object

    Example

    import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger';
    import middy from '@middy/core';


    const logger = new Logger();

    const lambdaHandler = async (_event: any, _context: any) => {
    logger.info('This is an INFO log with some context');
    };

    export const handler = middy(lambdaHandler).use(injectLambdaContext(logger));

Generated using TypeDoc