feat: make the app logger attached to the app instance public#2365
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. |
seratch
left a comment
There was a problem hiding this comment.
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.
zimeg
left a comment
There was a problem hiding this comment.
📝 Notes of the changes for the kind reviewers!
|
|
||
| /** Logger */ | ||
| private logger: Logger; | ||
| public logger: Logger; |
There was a problem hiding this comment.
Here's the update for tsc! 🎉
| | `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. | |
WilliamBergamin
left a comment
There was a problem hiding this comment.
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
loggerinstance to theappfor 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.loggerfunctions once theAppis constructed:Before changes
Using
console.loginstead ofapp.logger.infoprints the following:After changes
Documentation
Read more
Notes
typescriptspecific since before changesjavascriptapps could still useapp.logger! The change from this PR removes errors ifapp.loggeris used when runningtsc🧱Requirements