File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -156,8 +156,11 @@ Key | Example
156
156
}
157
157
158
158
export const myFunction = new Lambda();
159
- export const handler = myFunction.handler;
159
+ export const handler = myFunction.handler.bind(myFunction); // (1)
160
160
```
161
+
162
+ 1. Binding your handler method allows your handler to access `this` within the class methods.
163
+
161
164
=== "Manual"
162
165
163
166
```typescript hl_lines="7"
@@ -234,9 +237,11 @@ This is disabled by default to prevent sensitive info being logged
234
237
}
235
238
236
239
export const myFunction = new Lambda();
237
- export const handler = myFunction.handler;
240
+ export const handler = myFunction.handler.bind(myFunction); // (1)
238
241
```
239
242
243
+ 1. Binding your handler method allows your handler to access `this` within the class methods.
244
+
240
245
### Appending persistent additional log keys and values
241
246
242
247
You can append additional persistent keys and values in the logs generated during a Lambda invocation using either mechanism:
@@ -399,9 +404,11 @@ If you want to make sure that persistent attributes added **inside the handler f
399
404
}
400
405
401
406
export const myFunction = new Lambda();
402
- export const handler = myFunction.handler;
407
+ export const handler = myFunction.handler.bind(myFunction); // (1)
403
408
```
404
409
410
+ 1. Binding your handler method allows your handler to access `this` within the class methods.
411
+
405
412
In each case, the printed log will look like this:
406
413
407
414
=== "First invocation"
You can’t perform that action at this time.
0 commit comments