Added some logging to SlackBotChannel::class

This commit is contained in:
Deon George 2021-12-01 13:33:10 +11:00
parent edfb802805
commit e864d46430
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254

View File

@ -3,10 +3,14 @@
namespace Slack\Channels;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class SlackBotChannel
{
public function send($notifiable,Notification $notification)
private const LOGKEY = 'SBC';
public function send($notifiable,Notification $notification): void
{
if (! $co = $notifiable->routeNotificationFor('slackapp',$notification)) {
return;
@ -15,6 +19,14 @@ class SlackBotChannel
$o = $notification->toSlack($notifiable);
$o->setChannel($co);
return $o->post();
Log::debug(sprintf('%s:Sending Event to Channel [%s]',self::LOGKEY,$co->channel_id));
try {
$result = $o->post();
} catch (\Exception $e) {
Log::error(sprintf('Error posting to slack [%s]',$e->getMessage()));
return;
}
}
}