1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 05:07:36 +02:00

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.
This commit is contained in:
Alex Butter
2013-01-16 12:57:14 +01:00
parent 47eb599b4a
commit 448d5470f0

13
src/Monolog/Handler/PushoverHandler.php Normal file → Executable file
View File

@@ -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();
}
}