-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose logger to action handler (#8)
Add the logger instance to the context that is passed in to the action handler. This allows the action handler to send logs with the context established by the action wrapper. This means that you can do the following in your action handlers: ```ts const handler: ActionHandler<Context, Input, Output> = (ctx, input) => { ctx.logger.info('This is a log from inside the action handler'); // ...do something and return a result return doSomething(input); }; ``` And it will yield this log in addition to the normal logs that the wrapper emits: ``` [{DisplayName}:{CorrelationId}] Action Started (input: {input})] [{DisplayName}:{CorrelationId}] This is a log from inside the action handler [{DisplayName}:{CorrelationId}] Action Completed (data: {data})] ```
- Loading branch information
Showing
5 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
"@tnezdev/actions": minor | ||
--- | ||
|
||
Add the logger instance to the context that is passed in to the action handler. | ||
|
||
This allows the action handler to send logs with the context established by the action wrapper. | ||
|
||
This means that you can do the following in your action handlers: | ||
|
||
```ts | ||
const handler: ActionHandler<Context, Input, Output> = (ctx, input) => { | ||
ctx.logger.info("This is a log from inside the action handler"); | ||
|
||
// ...do something and return a result | ||
return doSomething(input); | ||
}; | ||
``` | ||
|
||
And it will yield this log in addition to the normal logs that the wrapper emits: | ||
|
||
``` | ||
[{DisplayName}:{CorrelationId}] Action Started (input: {input})] | ||
[{DisplayName}:{CorrelationId}] This is a log from inside the action handler | ||
[{DisplayName}:{CorrelationId}] Action Completed (data: {data})] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters