From d17cf064af7667d269bbae46f80c87521348d626 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 12 Jul 2015 11:20:49 +0100 Subject: [PATCH] Make sure flowdock handler is configured correctly, fixes #597 --- src/Monolog/Handler/FlowdockHandler.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Monolog/Handler/FlowdockHandler.php b/src/Monolog/Handler/FlowdockHandler.php index 6eaaa9d4..70656c88 100644 --- a/src/Monolog/Handler/FlowdockHandler.php +++ b/src/Monolog/Handler/FlowdockHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Logger; +use Monolog\Formatter\FlowdockFormatter; /** * Sends notifications through the Flowdock push API @@ -48,6 +49,28 @@ class FlowdockHandler extends SocketHandler $this->apiToken = $apiToken; } + /** + * {@inheritdoc} + */ + public function setFormatter(FormatterInterface $formatter) + { + if (!$formatter instanceof FlowdockFormatter) { + throw new \InvalidArgumentException('The FlowdockHandler requires an instance of Monolog\Formatter\FlowdockFormatter to function correctly'); + } + + return parent::setFormatter($formatter); + } + + /** + * Gets the default formatter. + * + * @return FormatterInterface + */ + protected function getDefaultFormatter() + { + throw new \InvalidArgumentException('The FlowdockHandler must be configured (via setFormatter) with an instance of Monolog\Formatter\FlowdockFormatter to function correctly'); + } + /** * {@inheritdoc} *