generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 180
Closed
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedloggerThis item relates to the Logger UtilityThis item relates to the Logger Utility
Milestone
Description
Bug description
After the refactoring introduced in #614 the Logger utility only allows to log values that are of type Error or string.
As such it's not possible anymore to log an arbitrary object, which causes unneeded friction since the point of logger is to promote structured logging.
As a trivial example, I might want to log the event of my function:
logger.debug('Lambda invoked', {
event: { event }
});This causes compile errors when using TypeScript (see below for details).
Expected Behavior
- Types allow passing strings,
Error, and arbitrary objects - Logger parses/structures each type correctly (i.e. strings are appended to a key & not broken down like it used to happen here,
Errorobjects are broken down correctly, other types of objects are appended)
Current Behavior
Argument of type '[{ details: { event: APIGatewayRequestAuthorizerEvent; }; }]' is not assignable to parameter of type 'LogItemExtraInput'.
Type '[{ details: { event: APIGatewayRequestAuthorizerEvent; }; }]' is not assignable to type '[string | Error]'.
Type '{ details: { event: APIGatewayRequestAuthorizerEvent; }; }' is not assignable to type 'string | Error'.
Object literal may only specify known properties, and 'details' does not exist in type 'Error'.ts(2345)
Possible Solution
N/A
Steps to Reproduce
import { APIGatewayRequestAuthorizerEvent } from 'aws-lambda';
import { Logger } from '@aws-lambda-powertools/logger';
const logger = new Logger({ logLevel: 'DEBUG' });
export const handler = async (event: APIGatewayRequestAuthorizerEvent) => {
logger.debug('Lambda invoked', {
details: { event }
});
return;
};Environment
- Powertools version used: v0.9.0
- Packaging format (Layers, npm): npm
- AWS Lambda function runtime: N/A
- Debugging logs: N/A
Related issues, RFCs
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedloggerThis item relates to the Logger UtilityThis item relates to the Logger Utility
