Skip to content

Commit 8d7a93e

Browse files
committed
Added lambdaInterface to logger examples
1 parent a0e8615 commit 8d7a93e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/core/logger.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,23 @@ Key | Example
145145

146146
=== "Decorator"
147147

148-
```typescript hl_lines="7"
148+
```typescript hl_lines="8"
149149
import { Logger } from "@aws-lambda-powertools/logger";
150+
import { LambdaInterface } from '@aws-lambda-powertools/commons';
150151

151152
const logger = new Logger();
152153

153-
class Lambda {
154+
class Lambda extends LambdaInterface {
154155
// Decorate your handler class method
155156
@logger.injectLambdaContext()
156-
public handler(_event: any, _context: any) {
157+
public async handler(_event: any, _context: any): Promise<unknown> {
157158
logger.info("This is an INFO log with some context");
158159
}
159160

160161
}
161162

162-
export const handlerClass = new Lambda();
163-
export const handler = handlerClass.handler;
163+
export const myFunction = new Lambda();
164+
export const handler = myFunction.handler;
164165
```
165166

166167
In each case, the printed log will look like this:

0 commit comments

Comments
 (0)