golden hour
/home/doctorbruno/.trash/google-site-kit/third-party/monolog/monolog/src/Monolog/Handler
⬆️ Go Up
Upload
File/Folder
Size
Actions
AbstractHandler.php
2.89 KB
Del
OK
AbstractProcessingHandler.php
2.03 KB
Del
OK
AbstractSyslogHandler.php
3.95 KB
Del
OK
AmqpHandler.php
5.24 KB
Del
OK
BrowserConsoleHandler.php
9.77 KB
Del
OK
BufferHandler.php
5.13 KB
Del
OK
ChromePHPHandler.php
5.56 KB
Del
OK
CouchDBHandler.php
2.19 KB
Del
OK
CubeHandler.php
5.6 KB
Del
OK
Curl
-
Del
OK
DeduplicationHandler.php
6.23 KB
Del
OK
DoctrineCouchDBHandler.php
1.47 KB
Del
OK
DynamoDbHandler.php
2.88 KB
Del
OK
ElasticaHandler.php
3.75 KB
Del
OK
ElasticsearchHandler.php
7.17 KB
Del
OK
ErrorLogHandler.php
2.85 KB
Del
OK
FallbackGroupHandler.php
1.79 KB
Del
OK
FilterHandler.php
7.68 KB
Del
OK
FingersCrossed
-
Del
OK
FingersCrossedHandler.php
9.3 KB
Del
OK
FirePHPHandler.php
5.32 KB
Del
OK
FleepHookHandler.php
3.65 KB
Del
OK
FlowdockHandler.php
3.86 KB
Del
OK
FormattableHandlerInterface.php
1.02 KB
Del
OK
FormattableHandlerTrait.php
1.57 KB
Del
OK
GelfHandler.php
1.72 KB
Del
OK
GroupHandler.php
3.58 KB
Del
OK
Handler.php
1.29 KB
Del
OK
HandlerInterface.php
2.99 KB
Del
OK
HandlerWrapper.php
4.15 KB
Del
OK
IFTTTHandler.php
2.37 KB
Del
OK
InsightOpsHandler.php
2.03 KB
Del
OK
LogEntriesHandler.php
1.88 KB
Del
OK
LogglyHandler.php
4.38 KB
Del
OK
LogmaticHandler.php
2.79 KB
Del
OK
MailHandler.php
2.51 KB
Del
OK
MandrillHandler.php
2.71 KB
Del
OK
MissingExtensionException.php
502 B
Del
OK
MongoDBHandler.php
2.91 KB
Del
OK
NativeMailerHandler.php
5.07 KB
Del
OK
NewRelicHandler.php
6.42 KB
Del
OK
NoopHandler.php
958 B
Del
OK
NullHandler.php
1.51 KB
Del
OK
OverflowHandler.php
5.11 KB
Del
OK
PHPConsoleHandler.php
11.14 KB
Del
OK
ProcessHandler.php
5.17 KB
Del
OK
ProcessableHandlerInterface.php
1.27 KB
Del
OK
ProcessableHandlerTrait.php
1.86 KB
Del
OK
PsrHandler.php
2.8 KB
Del
OK
PushoverHandler.php
7.92 KB
Del
OK
RedisHandler.php
3.21 KB
Del
OK
RedisPubSubHandler.php
2.09 KB
Del
OK
RollbarHandler.php
3.68 KB
Del
OK
RotatingFileHandler.php
6.46 KB
Del
OK
SamplingHandler.php
4.8 KB
Del
OK
SendGridHandler.php
3.04 KB
Del
OK
Slack
-
Del
OK
SlackHandler.php
7.08 KB
Del
OK
SlackWebhookHandler.php
4.19 KB
Del
OK
SocketHandler.php
12.09 KB
Del
OK
SqsHandler.php
1.97 KB
Del
OK
StreamHandler.php
8.57 KB
Del
OK
SwiftMailerHandler.php
4.14 KB
Del
OK
SymfonyMailerHandler.php
4.04 KB
Del
OK
SyslogHandler.php
2.08 KB
Del
OK
SyslogUdp
-
Del
OK
SyslogUdpHandler.php
4.66 KB
Del
OK
TelegramBotHandler.php
8.25 KB
Del
OK
TestHandler.php
6.8 KB
Del
OK
WebRequestRecognizerTrait.php
554 B
Del
OK
WhatFailureGroupHandler.php
1.98 KB
Del
OK
ZendMonitorHandler.php
3.78 KB
Del
OK
Edit: StreamHandler.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 Google\Site_Kit_Dependencies\Monolog\Handler; use Google\Site_Kit_Dependencies\Monolog\Logger; use Google\Site_Kit_Dependencies\Monolog\Utils; /** * Stores to any stream resource * * Can be used to store into php://stderr, remote and local files, etc. * * @author Jordi Boggiano <j.boggiano@seld.be> * * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class StreamHandler extends \Google\Site_Kit_Dependencies\Monolog\Handler\AbstractProcessingHandler { /** @const int */ protected const MAX_CHUNK_SIZE = 2147483647; /** @const int 10MB */ protected const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024; /** @var int */ protected $streamChunkSize; /** @var resource|null */ protected $stream; /** @var ?string */ protected $url = null; /** @var ?string */ private $errorMessage = null; /** @var ?int */ protected $filePermission; /** @var bool */ protected $useLocking; /** @var string */ protected $fileOpenMode; /** @var true|null */ private $dirCreated = null; /** @var bool */ private $retrying = \false; /** * @param resource|string $stream If a missing path can't be created, an UnexpectedValueException will be thrown on first write * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) * @param bool $useLocking Try to lock log file before doing any writes * @param string $fileOpenMode The fopen() mode used when opening a file, if $stream is a file path * * @throws \InvalidArgumentException If stream is not a resource or string */ public function __construct($stream, $level = \Google\Site_Kit_Dependencies\Monolog\Logger::DEBUG, bool $bubble = \true, ?int $filePermission = null, bool $useLocking = \false, $fileOpenMode = 'a') { parent::__construct($level, $bubble); if (($phpMemoryLimit = \Google\Site_Kit_Dependencies\Monolog\Utils::expandIniShorthandBytes(\ini_get('memory_limit'))) !== \false) { if ($phpMemoryLimit > 0) { // use max 10% of allowed memory for the chunk size, and at least 100KB $this->streamChunkSize = \min(static::MAX_CHUNK_SIZE, \max((int) ($phpMemoryLimit / 10), 100 * 1024)); } else { // memory is unlimited, set to the default 10MB $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE; } } else { // no memory limit information, set to the default 10MB $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE; } if (\is_resource($stream)) { $this->stream = $stream; \stream_set_chunk_size($this->stream, $this->streamChunkSize); } elseif (\is_string($stream)) { $this->url = \Google\Site_Kit_Dependencies\Monolog\Utils::canonicalizePath($stream); } else { throw new \InvalidArgumentException('A stream must either be a resource or a string.'); } $this->fileOpenMode = $fileOpenMode; $this->filePermission = $filePermission; $this->useLocking = $useLocking; } /** * {@inheritDoc} */ public function close() : void { if ($this->url && \is_resource($this->stream)) { \fclose($this->stream); } $this->stream = null; $this->dirCreated = null; } /** * Return the currently active stream if it is open * * @return resource|null */ public function getStream() { return $this->stream; } /** * Return the stream URL if it was configured with a URL and not an active resource * * @return string|null */ public function getUrl() : ?string { return $this->url; } /** * @return int */ public function getStreamChunkSize() : int { return $this->streamChunkSize; } /** * {@inheritDoc} */ protected function write(array $record) : void { if (!\is_resource($this->stream)) { $url = $this->url; if (null === $url || '' === $url) { throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().' . \Google\Site_Kit_Dependencies\Monolog\Utils::getRecordMessageForException($record)); } $this->createDir($url); $this->errorMessage = null; \set_error_handler(function (...$args) { return $this->customErrorHandler(...$args); }); try { $stream = \fopen($url, $this->fileOpenMode); if ($this->filePermission !== null) { @\chmod($url, $this->filePermission); } } finally { \restore_error_handler(); } if (!\is_resource($stream)) { $this->stream = null; throw new \UnexpectedValueException(\sprintf('The stream or file "%s" could not be opened in append mode: ' . $this->errorMessage, $url) . \Google\Site_Kit_Dependencies\Monolog\Utils::getRecordMessageForException($record)); } \stream_set_chunk_size($stream, $this->streamChunkSize); $this->stream = $stream; } $stream = $this->stream; if (!\is_resource($stream)) { throw new \LogicException('No stream was opened yet' . \Google\Site_Kit_Dependencies\Monolog\Utils::getRecordMessageForException($record)); } if ($this->useLocking) { // ignoring errors here, there's not much we can do about them \flock($stream, \LOCK_EX); } $this->errorMessage = null; \set_error_handler(function (...$args) { return $this->customErrorHandler(...$args); }); try { $this->streamWrite($stream, $record); } finally { \restore_error_handler(); } if ($this->errorMessage !== null) { $error = $this->errorMessage; // close the resource if possible to reopen it, and retry the failed write if (!$this->retrying && $this->url !== null && $this->url !== 'php://memory') { $this->retrying = \true; $this->close(); $this->write($record); return; } throw new \UnexpectedValueException('Writing to the log file failed: ' . $error . \Google\Site_Kit_Dependencies\Monolog\Utils::getRecordMessageForException($record)); } $this->retrying = \false; if ($this->useLocking) { \flock($stream, \LOCK_UN); } } /** * Write to stream * @param resource $stream * @param array $record * * @phpstan-param FormattedRecord $record */ protected function streamWrite($stream, array $record) : void { \fwrite($stream, (string) $record['formatted']); } private function customErrorHandler(int $code, string $msg) : bool { $this->errorMessage = \preg_replace('{^(fopen|mkdir|fwrite)\\(.*?\\): }', '', $msg); return \true; } private function getDirFromStream(string $stream) : ?string { $pos = \strpos($stream, '://'); if ($pos === \false) { return \dirname($stream); } if ('file://' === \substr($stream, 0, 7)) { return \dirname(\substr($stream, 7)); } return null; } private function createDir(string $url) : void { // Do not try to create dir if it has already been tried. if ($this->dirCreated) { return; } $dir = $this->getDirFromStream($url); if (null !== $dir && !\is_dir($dir)) { $this->errorMessage = null; \set_error_handler(function (...$args) { return $this->customErrorHandler(...$args); }); $status = \mkdir($dir, 0777, \true); \restore_error_handler(); if (\false === $status && !\is_dir($dir) && \strpos((string) $this->errorMessage, 'File exists') === \false) { throw new \UnexpectedValueException(\sprintf('There is no existing directory at "%s" and it could not be created: ' . $this->errorMessage, $dir)); } } $this->dirCreated = \true; } }
Save