From 448d5470f08efb555421cc7af33cae004d12e3a4 Mon Sep 17 00:00:00 2001 From: Alex Butter Date: Wed, 16 Jan 2013 12:57:14 +0100 Subject: [PATCH] Option to use SSL for PushoverHandler (enabled by default), and close connection after sending a message to PushOver. Solves #146: When sending messages in rapid succession to pushover.net only the first one is sent. The SSL option is needed when sending messages to users that are not the pushover.net app owner; pushover.net doesn't accept those messages over plain HTTP. --- src/Monolog/Handler/PushoverHandler.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/Monolog/Handler/PushoverHandler.php diff --git a/src/Monolog/Handler/PushoverHandler.php b/src/Monolog/Handler/PushoverHandler.php old mode 100644 new mode 100755 index c5115f46..06818393 --- a/src/Monolog/Handler/PushoverHandler.php +++ b/src/Monolog/Handler/PushoverHandler.php @@ -31,10 +31,13 @@ class PushoverHandler extends SocketHandler * @param string $title Title sent to Pushover API * @param integer $level The minimum logging level at which this handler will be triggered * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param Boolean $useSSL Whether to connect via SSL. Required when pushing messages to users that are not + * the pushover.net app owner. OpenSSL is required for this option. */ - public function __construct($token, $user, $title = null, $level = Logger::CRITICAL, $bubble = true) + public function __construct($token, $user, $title = null, $level = Logger::CRITICAL, $bubble = true, $useSSL = true) { - parent::__construct('api.pushover.net:80', $level, $bubble); + $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80'; + parent::__construct($connectionString, $level, $bubble); $this->token = $token; $this->user = $user; @@ -76,4 +79,10 @@ class PushoverHandler extends SocketHandler return $header; } + + public function write(array $record) + { + parent::write($record); + $this->closeSocket(); + } }