devorto / slack-logger
Logs errors/notices etc to slack using Psr/LoggerInterface.
This package is auto-updated.
Last update: 2025-02-25 22:38:28 UTC
README
Send errors/notices/warnings etc to slack, using this Class which implements the Prs/Log/LoggerInterface.
For more information about the logger interface or log levels see their github.
Setup webhook
Before you can use this you need to setup a webhook app in slack and connect this to the channel you want to use.
- Goto https://api.slack.com/apps.
- Click on the "New App" button on the top right.
- Fill in a "App Name" (this will be the sender name in slack)
- Fill in on which "Development Slack Workspace" you want to have it installed.
- Click on "Create App".
- In section "Add features and functionality" select "Incoming Webhooks".
- Set "Activate Incoming Webhooks" to "On" on the right.
- This will unfold new options and now click on "Add New Webhook to Workspace" on the bottom of the page.
- This will bring you to a new page, select on which channel you want the message to be posted.
- Click on "Install".
- This will bring you back to the webhook page, now on the bottom of the page copy the webhook url. This url is what you need in below example.
Example
<?php $slack = new \Devorto\Logger\Slack( '<paste-webhook-url-here>', 'My Test App', 'https://test.example.com' // Optional app url. ); // Use one of the available log level methods: $slack->critical('Help something went critical.'); // You can also drop an Exception in here. $slack->critical(new Exception('Test'));