Skip to content

Commit 95a6bb6

Browse files
committed
chore: updated docs
1 parent bfe1e8f commit 95a6bb6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/core/logger.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ Key | Example
156156
}
157157

158158
export const myFunction = new Lambda();
159-
export const handler = myFunction.handler;
159+
export const handler = myFunction.handler.bind(myFunction); // (1)
160160
```
161+
162+
1. Binding your handler method allows your handler to access `this` within the class methods.
163+
161164
=== "Manual"
162165

163166
```typescript hl_lines="7"
@@ -234,9 +237,11 @@ This is disabled by default to prevent sensitive info being logged
234237
}
235238

236239
export const myFunction = new Lambda();
237-
export const handler = myFunction.handler;
240+
export const handler = myFunction.handler.bind(myFunction); // (1)
238241
```
239242

243+
1. Binding your handler method allows your handler to access `this` within the class methods.
244+
240245
### Appending persistent additional log keys and values
241246

242247
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
399404
}
400405

401406
export const myFunction = new Lambda();
402-
export const handler = myFunction.handler;
407+
export const handler = myFunction.handler.bind(myFunction); // (1)
403408
```
404409

410+
1. Binding your handler method allows your handler to access `this` within the class methods.
411+
405412
In each case, the printed log will look like this:
406413

407414
=== "First invocation"

0 commit comments

Comments
 (0)