diff --git a/src/Monolog/Handler/FleepHookHandler.php b/src/Monolog/Handler/FleepHookHandler.php index a938c1f6..8f8a8d3d 100644 --- a/src/Monolog/Handler/FleepHookHandler.php +++ b/src/Monolog/Handler/FleepHookHandler.php @@ -15,7 +15,9 @@ use Monolog\Formatter\LineFormatter; use Monolog\Logger; /** - * Sends logs to Fleep.io using WebHook integrations + * Sends logs to Fleep.io using Webhook integrations + * + * You'll need a Fleep.io account to use this handler. * * @see https://fleep.io/integrations/webhooks/ Fleep Webhooks Documentation * @author Ando Roots @@ -23,9 +25,6 @@ use Monolog\Logger; class FleepHookHandler extends AbstractProcessingHandler { - /** - * Fleep.io webhooks URI - */ const HOOK_ENDPOINT = 'https://fleep.io/hook/'; /** @@ -52,11 +51,10 @@ class FleepHookHandler extends AbstractProcessingHandler /** * Construct a new Fleep.io Handler. * - * You'll need a Fleep.op account to use this handler. * For instructions on how to create a new web hook in your conversations * see https://fleep.io/integrations/webhooks/ * - * @param string $token Webhook token (ex: mTZG6s-XRfKdNTJtpVyVaA) + * @param string $token Webhook token * @param bool|int $level The minimum logging level at which this handler will be triggered * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @throws \LogicException @@ -73,14 +71,6 @@ class FleepHookHandler extends AbstractProcessingHandler parent::__construct($level, $bubble); } - /** - * @return string - */ - public function getToken() - { - return $this->token; - } - /** * @return array */ @@ -94,10 +84,9 @@ class FleepHookHandler extends AbstractProcessingHandler * * Overloaded to remove empty context and extra arrays from the end of the log message. * - * @author Ando Roots * @return LineFormatter */ - public function getDefaultFormatter() + protected function getDefaultFormatter() { return new LineFormatter(null, null, true, true); @@ -106,7 +95,6 @@ class FleepHookHandler extends AbstractProcessingHandler /** * Handles a log record * - * @author Ando Roots * @param array $record */ protected function write(array $record) @@ -118,7 +106,6 @@ class FleepHookHandler extends AbstractProcessingHandler /** * Prepares the record for sending to Fleep * - * @author Ando Roots * @param string $message The formatted log message to send */ protected function send($message) @@ -137,7 +124,6 @@ class FleepHookHandler extends AbstractProcessingHandler /** * Sends a new Curl request * - * @author Ando Roots * @param array $options Curl parameters, including the endpoint URL and POST payload */ protected function execCurl(array $options) @@ -154,7 +140,6 @@ class FleepHookHandler extends AbstractProcessingHandler /** * Adds or overwrites a curl option * - * @author Ando Roots * @param array $options An assoc array of Curl options, indexed by CURL_* constants * @return $this */ diff --git a/tests/Monolog/Handler/FleepHookHandlerTest.php b/tests/Monolog/Handler/FleepHookHandlerTest.php index 61290182..2eeb167a 100644 --- a/tests/Monolog/Handler/FleepHookHandlerTest.php +++ b/tests/Monolog/Handler/FleepHookHandlerTest.php @@ -58,7 +58,22 @@ class FleepHookHandlerTest extends TestCase */ public function testConstructorSetsExpectedDefaults() { - $this->assertEquals(self::TOKEN, $this->handler->getToken()); + // Test that the $token is saved when calling the constructor + $token = self::TOKEN; + $handler = $this->mockHandler(array('execCurl')); + $handler->expects($this->once()) + ->method('execCurl') + ->with( + $this->callback( + function ($curlOpts) use ($token) { + return substr($curlOpts[CURLOPT_URL], -strlen($token)) === $token; + } + ) + ); + + $this->sendLog($handler); + + // Test that default values are assigned to $level and $bubble $this->assertEquals(Logger::DEBUG, $this->handler->getLevel()); $this->assertEquals(true, $this->handler->getBubble()); } @@ -102,7 +117,7 @@ class FleepHookHandlerTest extends TestCase $expectedFormatter = new LineFormatter(null, null, true, true); $expected = $expectedFormatter->format($record); - $handlerFormatter = $this->handler->getDefaultFormatter(); + $handlerFormatter = $this->handler->getFormatter(); $actual = $handlerFormatter->format($record); $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered');