X7ROOT File Manager
Current Path:
/home/prisjneg/public_html/vendor/monolog/monolog/src/Monolog/Handler
home
/
prisjneg
/
public_html
/
vendor
/
monolog
/
monolog
/
src
/
Monolog
/
Handler
/
π
..
π
AbstractHandler.php
(2.61 KB)
π
AbstractProcessingHandler.php
(1.46 KB)
π
AbstractSyslogHandler.php
(3.15 KB)
π
AmqpHandler.php
(4.95 KB)
π
BrowserConsoleHandler.php
(9.02 KB)
π
BufferHandler.php
(4.55 KB)
π
ChromePHPHandler.php
(4.79 KB)
π
CouchDBHandler.php
(2.55 KB)
π
CubeHandler.php
(5.32 KB)
π
Curl
π
DeduplicationHandler.php
(6.25 KB)
π
DoctrineCouchDBHandler.php
(1.12 KB)
π
DynamoDbHandler.php
(1.89 KB)
π
ElasticaHandler.php
(3.66 KB)
π
ElasticsearchHandler.php
(7.1 KB)
π
ErrorLogHandler.php
(2.61 KB)
π
FallbackGroupHandler.php
(1.68 KB)
π
FilterHandler.php
(6.92 KB)
π
FingersCrossed
π
FingersCrossedHandler.php
(7.99 KB)
π
FirePHPHandler.php
(5.03 KB)
π
FleepHookHandler.php
(3.44 KB)
π
FlowdockHandler.php
(3.4 KB)
π
FormattableHandlerInterface.php
(757 B)
π
FormattableHandlerTrait.php
(1.24 KB)
π
GelfHandler.php
(1.42 KB)
π
GroupHandler.php
(3.19 KB)
π
Handler.php
(1.21 KB)
π
HandlerInterface.php
(2.71 KB)
π
HandlerWrapper.php
(3.28 KB)
π
IFTTTHandler.php
(2.22 KB)
π
InsightOpsHandler.php
(2.04 KB)
π
LogEntriesHandler.php
(1.86 KB)
π
LogglyHandler.php
(4.02 KB)
π
LogmaticHandler.php
(2.57 KB)
π
MailHandler.php
(2.19 KB)
π
MandrillHandler.php
(2.48 KB)
π
MissingExtensionException.php
(473 B)
π
MongoDBHandler.php
(2.31 KB)
π
NativeMailerHandler.php
(5.08 KB)
π
NewRelicHandler.php
(5.7 KB)
π
NoopHandler.php
(908 B)
π
NullHandler.php
(1.3 KB)
π
OverflowHandler.php
(4.21 KB)
π
PHPConsoleHandler.php
(12.01 KB)
π
ProcessHandler.php
(5.36 KB)
π
ProcessableHandlerInterface.php
(1.16 KB)
π
ProcessableHandlerTrait.php
(1.58 KB)
π
PsrHandler.php
(2.41 KB)
π
PushoverHandler.php
(7.92 KB)
π
RedisHandler.php
(2.67 KB)
π
RedisPubSubHandler.php
(1.64 KB)
π
RollbarHandler.php
(3.48 KB)
π
RotatingFileHandler.php
(6.97 KB)
π
SamplingHandler.php
(3.83 KB)
π
SendGridHandler.php
(3.02 KB)
π
Slack
π
SlackHandler.php
(6.99 KB)
π
SlackWebhookHandler.php
(3.79 KB)
π
SocketHandler.php
(11.84 KB)
π
SqsHandler.php
(1.71 KB)
π
StreamHandler.php
(7.96 KB)
π
SymfonyMailerHandler.php
(3.45 KB)
π
SyslogHandler.php
(1.65 KB)
π
SyslogUdp
π
SyslogUdpHandler.php
(4.6 KB)
π
TelegramBotHandler.php
(9.22 KB)
π
TestHandler.php
(6.6 KB)
π
WebRequestRecognizerTrait.php
(504 B)
π
WhatFailureGroupHandler.php
(1.87 KB)
π
ZendMonitorHandler.php
(2.78 KB)
Editing: PushoverHandler.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; use Monolog\Logger; use Monolog\Utils; use Psr\Log\LogLevel; use Monolog\LogRecord; /** * Sends notifications through the pushover api to mobile phones * * @author Sebastian GΓΆttschkes <sebastian.goettschkes@googlemail.com> * @see https://www.pushover.net/api */ class PushoverHandler extends SocketHandler { private string $token; /** @var array<int|string> */ private array $users; private string $title; private string|int|null $user = null; private int $retry; private int $expire; private Level $highPriorityLevel; private Level $emergencyLevel; private bool $useFormattedMessage = false; /** * All parameters that can be sent to Pushover * @see https://pushover.net/api * @var array<string, bool> */ private array $parameterNames = [ 'token' => true, 'user' => true, 'message' => true, 'device' => true, 'title' => true, 'url' => true, 'url_title' => true, 'priority' => true, 'timestamp' => true, 'sound' => true, 'retry' => true, 'expire' => true, 'callback' => true, ]; /** * Sounds the api supports by default * @see https://pushover.net/api#sounds * @var string[] */ private array $sounds = [ 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', 'persistent', 'echo', 'updown', 'none', ]; /** * @param string $token Pushover api token * @param string|array $users Pushover user id or array of ids the message will be sent to * @param string|null $title Title sent to the Pushover API * @param bool $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. * @param int $retry The retry parameter specifies how often (in seconds) the Pushover servers will * send the same notification to the user. * @param int $expire The expire parameter specifies how many seconds your notification will continue * to be retried for (every retry seconds). * * @param int|string|Level|LogLevel::* $highPriorityLevel The minimum logging level at which this handler will start * sending "high priority" requests to the Pushover API * @param int|string|Level|LogLevel::* $emergencyLevel The minimum logging level at which this handler will start * sending "emergency" requests to the Pushover API * * * @phpstan-param string|array<int|string> $users * @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $highPriorityLevel * @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $emergencyLevel */ public function __construct( string $token, $users, ?string $title = null, int|string|Level $level = Level::Critical, bool $bubble = true, bool $useSSL = true, int|string|Level $highPriorityLevel = Level::Critical, int|string|Level $emergencyLevel = Level::Emergency, int $retry = 30, int $expire = 25200, bool $persistent = false, float $timeout = 0.0, float $writingTimeout = 10.0, ?float $connectionTimeout = null, ?int $chunkSize = null ) { $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80'; parent::__construct( $connectionString, $level, $bubble, $persistent, $timeout, $writingTimeout, $connectionTimeout, $chunkSize ); $this->token = $token; $this->users = (array) $users; $this->title = $title ?? (string) gethostname(); $this->highPriorityLevel = Logger::toMonologLevel($highPriorityLevel); $this->emergencyLevel = Logger::toMonologLevel($emergencyLevel); $this->retry = $retry; $this->expire = $expire; } protected function generateDataStream(LogRecord $record): string { $content = $this->buildContent($record); return $this->buildHeader($content) . $content; } private function buildContent(LogRecord $record): string { // Pushover has a limit of 512 characters on title and message combined. $maxMessageLength = 512 - \strlen($this->title); $message = ($this->useFormattedMessage) ? $record->formatted : $record->message; $message = Utils::substr($message, 0, $maxMessageLength); $timestamp = $record->datetime->getTimestamp(); $dataArray = [ 'token' => $this->token, 'user' => $this->user, 'message' => $message, 'title' => $this->title, 'timestamp' => $timestamp, ]; if ($record->level->value >= $this->emergencyLevel->value) { $dataArray['priority'] = 2; $dataArray['retry'] = $this->retry; $dataArray['expire'] = $this->expire; } elseif ($record->level->value >= $this->highPriorityLevel->value) { $dataArray['priority'] = 1; } // First determine the available parameters $context = array_intersect_key($record->context, $this->parameterNames); $extra = array_intersect_key($record->extra, $this->parameterNames); // Least important info should be merged with subsequent info $dataArray = array_merge($extra, $context, $dataArray); // Only pass sounds that are supported by the API if (isset($dataArray['sound']) && !\in_array($dataArray['sound'], $this->sounds, true)) { unset($dataArray['sound']); } return http_build_query($dataArray); } private function buildHeader(string $content): string { $header = "POST /1/messages.json HTTP/1.1\r\n"; $header .= "Host: api.pushover.net\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . \strlen($content) . "\r\n"; $header .= "\r\n"; return $header; } protected function write(LogRecord $record): void { foreach ($this->users as $user) { $this->user = $user; parent::write($record); $this->closeSocket(); } $this->user = null; } /** * @param int|string|Level|LogLevel::* $level * @return $this * * @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $level */ public function setHighPriorityLevel(int|string|Level $level): self { $this->highPriorityLevel = Logger::toMonologLevel($level); return $this; } /** * @param int|string|Level|LogLevel::* $level * @return $this * * @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $level */ public function setEmergencyLevel(int|string|Level $level): self { $this->emergencyLevel = Logger::toMonologLevel($level); return $this; } /** * Use the formatted message? * * @return $this */ public function useFormattedMessage(bool $useFormattedMessage): self { $this->useFormattedMessage = $useFormattedMessage; return $this; } }
Upload File
Create Folder