@loglayer/transport-aws-lambda-powertools
v2.0.0
Published
AWS Lambda Powertools logger transport for LogLayer
Downloads
318
Maintainers
Readme
AWS Lambda Powertools Logger Transport for LogLayer
A LogLayer transport for AWS Lambda Powertools Logger.
Installation
npm install loglayer @loglayer/transport-aws-lambda-powertools @aws-lambda-powertools/logger
Usage
import { Logger } from '@aws-lambda-powertools/logger';
import { LogLayer } from 'loglayer';
import { PowertoolsTransport } from '@loglayer/transport-aws-lambda-powertools';
// Note: The Logger utility must always be instantiated outside the Lambda handler
// Create a new Powertools logger instance
const powertoolsLogger = new Logger({
serviceName: 'my-service',
logLevel: 'INFO'
});
// Create LogLayer instance with Powertools transport
const log = new LogLayer({
transport: new PowertoolsTransport({
logger: powertoolsLogger
})
});
// Use LogLayer as normal
log.withMetadata({ customField: 'value' }).info('Hello from Lambda!');
Log Level Mapping
| LogLayer | Powertools | |----------|------------| | trace | DEBUG | | debug | DEBUG | | info | INFO | | warn | WARN | | error | ERROR | | fatal | ERROR |
License
MIT