| 1 |
<?php |
| 2 |
/** |
| 3 |
* Pushover handler for Monolog |
| 4 |
* |
| 5 |
* Handles all features of Pushover handler for Monolog. |
| 6 |
* |
| 7 |
* @package Handlers |
| 8 |
* @author Pierre Lannoy <https://pierre.lannoy.fr/>. |
| 9 |
* @since 1.3.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace Decalog\Handler; |
| 13 |
|
| 14 |
use DLMonolog\Logger; |
| 15 |
use DLMonolog\Handler\PushoverHandler; |
| 16 |
|
| 17 |
/** |
| 18 |
* Define the Monolog Pushover handler. |
| 19 |
* |
| 20 |
* Handles all features of Pushover handler for Monolog. |
| 21 |
* |
| 22 |
* @package Handlers |
| 23 |
* @author Pierre Lannoy <https://pierre.lannoy.fr/>. |
| 24 |
* @since 1.3.0 |
| 25 |
*/ |
| 26 |
class PshHandler extends PushoverHandler { |
| 27 |
|
| 28 |
/** |
| 29 |
* Initialize the class and set its properties. |
| 30 |
* |
| 31 |
* @param string $token Pushover api token. |
| 32 |
* @param string|array $users Pushover user id or array of ids the message will be sent to. |
| 33 |
* @param string|null $title Optional. Title sent to the Pushover API. |
| 34 |
* @param integer $timeout Optional. The socket timeout. |
| 35 |
* @param int|string $level The minimum logging level at which this handler will be triggered. |
| 36 |
* @since 1.3.0 |
| 37 |
*/ |
| 38 |
public function __construct( $token, $users, $title = null, $timeout = 1000, $level = Logger::CRITICAL ) { |
| 39 |
$new_timeout = (int) round($timeout / 1000); |
| 40 |
$old_timeout = ini_get( 'default_socket_timeout' ); |
| 41 |
// phpcs:ignore |
| 42 |
ini_set( 'default_socket_timeout', (string) $new_timeout ); |
| 43 |
parent::__construct( $token, $users, $title, $level, true, true ); |
| 44 |
// phpcs:ignore |
| 45 |
ini_set( 'default_socket_timeout', (string) $old_timeout ); |
| 46 |
} |
| 47 |
} |
| 48 |
|