/home/techb158/immovalet.com/vendor/monolog/monolog/src/Monolog/Handler
NameSizeModeActions
Curl/-0755rm
FingersCrossed/-0755rm
Slack/-0755rm
SyslogUdp/-0755rm
AbstractHandler.php26510644editdlrm
AbstractProcessingHandler.php19140644editdlrm
AbstractSyslogHandler.php35400644editdlrm
AmqpHandler.php39400644editdlrm
BrowserConsoleHandler.php83820644editdlrm
BufferHandler.php46440644editdlrm
ChromePHPHandler.php52290644editdlrm
CouchDBHandler.php21030644editdlrm
CubeHandler.php52850644editdlrm
DeduplicationHandler.php60630644editdlrm
DoctrineCouchDBHandler.php11280644editdlrm
DynamoDbHandler.php24820644editdlrm
ElasticaHandler.php33280644editdlrm
ElasticsearchHandler.php52970644editdlrm
ErrorLogHandler.php25870644editdlrm
FallbackGroupHandler.php17610644editdlrm
FilterHandler.php68430644editdlrm
FingersCrossedHandler.php84690644editdlrm
FirePHPHandler.php52880644editdlrm
FleepHookHandler.php32130644editdlrm
FlowdockHandler.php31380644editdlrm
FormattableHandlerInterface.php8450644editdlrm
FormattableHandlerTrait.php12810644editdlrm
GelfHandler.php13990644editdlrm
GroupHandler.php32340644editdlrm
Handler.php10290644editdlrm
HandlerInterface.php30320644editdlrm
HandlerWrapper.php33580644editdlrm
IFTTTHandler.php20260644editdlrm
InsightOpsHandler.php17100644editdlrm
LogEntriesHandler.php15290644editdlrm
LogglyHandler.php40980644editdlrm
LogmaticHandler.php23120644editdlrm
MailHandler.php23410644editdlrm
MandrillHandler.php24730644editdlrm
MissingExtensionException.php4730644editdlrm
MongoDBHandler.php25450644editdlrm
NativeMailerHandler.php49710644editdlrm
NewRelicHandler.php62110644editdlrm
NoopHandler.php8800644editdlrm
NullHandler.php13370644editdlrm
OverflowHandler.php45330644editdlrm
PHPConsoleHandler.php104720644editdlrm
ProcessableHandlerInterface.php11970644editdlrm
ProcessableHandlerTrait.php17370644editdlrm
ProcessHandler.php52150644editdlrm
PsrHandler.php24400644editdlrm
PushoverHandler.php77310644editdlrm
RedisHandler.php29880644editdlrm
RedisPubSubHandler.php17880644editdlrm
RollbarHandler.php34120644editdlrm
RotatingFileHandler.php62300644editdlrm
SamplingHandler.php43380644editdlrm
SendGridHandler.php27110644editdlrm
SlackHandler.php66660644editdlrm
SlackWebhookHandler.php37590644editdlrm
SocketHandler.php108660644editdlrm
SqsHandler.php16990644editdlrm
StreamHandler.php58080644editdlrm
SwiftMailerHandler.php33420644editdlrm
SyslogHandler.php18410644editdlrm
SyslogUdpHandler.php42870644editdlrm
TelegramBotHandler.php55150644editdlrm
TestHandler.php67500644editdlrm
WebRequestRecognizerTrait.php5240644editdlrm
WhatFailureGroupHandler.php16690644editdlrm
ZendMonitorHandler.php31370644editdlrm
Edit: /home/techb158/immovalet.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php (5808B)
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Logger; use Monolog\Utils; /** * Stores to any stream resource * * Can be used to store into php://stderr, remote and local files, etc. * * @author Jordi Boggiano * * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class StreamHandler extends AbstractProcessingHandler { protected const MAX_CHUNK_SIZE = 2147483647; /** @var resource|null */ protected $stream; /** @var ?string */ protected $url = null; /** @var ?string */ private $errorMessage = null; /** @var ?int */ protected $filePermission; /** @var bool */ protected $useLocking; /** @var true|null */ private $dirCreated = null; /** * @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 * * @throws \InvalidArgumentException If stream is not a resource or string */ public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) { parent::__construct($level, $bubble); if (is_resource($stream)) { $this->stream = $stream; stream_set_chunk_size($this->stream, self::MAX_CHUNK_SIZE); } elseif (is_string($stream)) { $this->url = Utils::canonicalizePath($stream); } else { throw new \InvalidArgumentException('A stream must either be a resource or a string.'); } $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; } /** * {@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().'); } $this->createDir($url); $this->errorMessage = null; set_error_handler([$this, 'customErrorHandler']); $stream = fopen($url, 'a'); if ($this->filePermission !== null) { @chmod($url, $this->filePermission); } 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)); } stream_set_chunk_size($stream, self::MAX_CHUNK_SIZE); $this->stream = $stream; } $stream = $this->stream; if (!is_resource($stream)) { throw new \LogicException('No stream was opened yet'); } if ($this->useLocking) { // ignoring errors here, there's not much we can do about them flock($stream, LOCK_EX); } $this->streamWrite($stream, $record); 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)\(.*?\): }', '', $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([$this, 'customErrorHandler']); $status = mkdir($dir, 0777, true); restore_error_handler(); if (false === $status && !is_dir($dir)) { throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: '.$this->errorMessage, $dir)); } } $this->dirCreated = true; } }