-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make the app logger attached to the app instance public #2365
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #2365 +/- ##
=======================================
Coverage 92.59% 92.59%
=======================================
Files 36 36
Lines 7472 7472
Branches 653 653
=======================================
Hits 6919 6919
Misses 545 545
Partials 8 8 β View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Looks good to me, but you may want to wait for others' feedback for one or two business days. Also, this PR includes document changes too, so we should release a new version including the change as early as possible once it's merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Notes of the changes for the kind reviewers!
@@ -222,7 +222,7 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed> | |||
private receiver: Receiver; | |||
|
|||
/** Logger */ | |||
private logger: Logger; | |||
public logger: Logger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the update for tsc
! π
@@ -48,6 +48,7 @@ Listener functions have access to a set of arguments that may change based on th | |||
| `respond` | `action`, `shortcut`, `view`, `command` | Function that responds to an incoming event **if** it contains a `response_url`. `respond` returns a promise that resolves with the results of responding using the `response_url`. For shortcuts, `respond` will **only** work for message shortcuts (not global shortcuts). For views, `respond` will **only** work when using `response_url_enabled: true` for [conversations list](https://api.slack.com/reference/block-kit/block-elements#conversation_select) and [channels list](https://api.slack.com/reference/block-kit/block-elements#channel_select) select menus in input blocks in modals. | | |||
| `context` | All listeners | Event context. This object contains data about the event and the app, such as the `botId`. Middleware can add additional context before the event is passed to listeners. | | |||
| `body` | All listeners | Object that contains the entire body of the request (superset of `payload`). Some accessory data is only available outside of the payload (such as `trigger_id` and `authorizations`). | | |||
| `logger` | All listeners | The application logger with all of [the logging functions](/concepts/logging) for output. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me as well π― seem like this was originally set to private and never revisited
This behavior also aligns with the bolt python behavior
@seratch @WilliamBergamin Thank y'all both for reviewing! I'm tagging @lukegalbraithrussell here for awareness on updates to docs, and will plan on merging this right before the next release is tagged - good catch with the docs differences that'd appear with an earlier merge! π β¨ |
@seratch @WilliamBergamin @lukegalbraithrussell thank y'all all for the reviews! I'm glad that we find another match between We're set to release this in the next version with #2371 and testing continues to pass as expected so I think now's a good time to merge! π’ π¨ I'll begin the updates to included examples for another PR π |
Summary
This PR adds the
logger
instance to theapp
for logging outside of function listeners, as this comment suggests:slack-samples/bolt-js-starter-template#84 (review) πΎ β¨
Preview
Updated app code can use the
app.logger
functions once theApp
is constructed:Before changes
Using
console.log
instead ofapp.logger.info
prints the following:After changes
Documentation
Read more
Notes
typescript
specific since before changesjavascript
apps could still useapp.logger
! The change from this PR removes errors ifapp.logger
is used when runningtsc
π§±Requirements