Skip to content

Commit

Permalink
Log when beacon fails to send
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Jan 2, 2017
1 parent a2bbb18 commit 34b0432
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
34 changes: 34 additions & 0 deletions app/Bus/Handlers/Events/Beacon/LogBeaconFailedHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Cachet\Bus\Handlers\Events\Beacon;

use CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent;

/**
* This is the log beacon failed handler.
*
* @author James Brooks <[email protected]>
*/
class LogBeaconFailedHandler
{
/**
* Handle the event.
*
* @param \CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent $event
*
* @return void
*/
public function handle(BeaconFailedToSendEvent $event)
{
logger('Beacon failed.');
}
}
2 changes: 1 addition & 1 deletion app/Foundation/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EventServiceProvider extends ServiceProvider
*/
protected $listen = [
'CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent' => [
//
'CachetHQ\Cachet\Bus\Handlers\Events\Beacon\LogBeaconFailedHandler',
],
'CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent' => [
//
Expand Down
1 change: 0 additions & 1 deletion app/Integrations/Core/Beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public function send()
'json' => $payload,
]);
} catch (Exception $e) {
// TODO: Log a warning that the beacon could not be sent.
event(new BeaconFailedToSendEvent());

return;
Expand Down
2 changes: 1 addition & 1 deletion tests/Bus/Events/Beacon/BeaconFailedToSendEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BeaconFailedToSendEventTest extends AbstractBeaconEventTestCase
{
protected function objectHasHandlers()
{
return false;
return true;
}

protected function getObjectAndParams()
Expand Down

0 comments on commit 34b0432

Please sign in to comment.