It initializes the Logger class with an optional set of options (settings). *
It adds the current Lambda function's invocation context data to the powertoolLogData property of the instance. This context data will be part of all printed log items.
It adds the given attributes (key-value pairs) to all log items generated by this Logger instance.
Alias for addPersistentLogAttributes.
It creates a separate Logger instance, identical to the current one It's possible to overwrite the new instance options by passing them.
It prints a log item with level DEBUG.
It prints a log item with level ERROR.
It returns a boolean value. True means that the Lambda invocation events are printed in the logs.
It returns a boolean value, if true all the logs will be printed.
It prints a log item with level INFO.
Method decorator that adds the current Lambda function context as extra information in all log items. The decorator can be used only when attached to a Lambda function handler which is written as method of a class, and should be declared just before the handler declaration.
Logs a Lambda invocation event, if it should.
If the sample rate feature is enabled, the calculation that determines whether the logs will actually be printed or not for this invocation is done when the Logger class is initialized. This method will repeat that calculation (with possible different outcome).
Alias for removePersistentLogAttributes.
It removes attributes based on provided keys to all log items generated by this Logger instance.
It sets the given attributes (key-value pairs) to all log items generated by this Logger instance. Note: this replaces the pre-existing value.
It sets the user-provided sample rate value.
It prints a log item with level WARN.
Generated using TypeDoc
Intro
The Logger utility provides an opinionated logger with output structured as JSON.
Key features
Usage
For more usage examples, see our documentation.
Basic usage
Functions usage with manual instrumentation
If you prefer to manually instrument your Lambda handler you can use the methods in the Logger class directly.
Functions usage with middleware
If you use function-based Lambda handlers you can use the injectLambdaContext() middy middleware to automatically add context to your Lambda logs.
Object oriented usage with decorators
If instead you use TypeScript classes to wrap your Lambda handler you can use the @logger.injectLambdaContext() decorator.
{ClassThatLogs}
https://awslabs.github.io/aws-lambda-powertools-typescript/latest/core/logger/