golden hour
/home/doctorbruno/.trash/google-site-kit.1/third-party/monolog/monolog/src/Monolog/Handler
⬆️ Go Up
Upload
File/Folder
Size
Actions
AbstractHandler.php
2.69 KB
Del
OK
AbstractProcessingHandler.php
1.89 KB
Del
OK
AbstractSyslogHandler.php
3.47 KB
Del
OK
AmqpHandler.php
4.86 KB
Del
OK
BrowserConsoleHandler.php
9.17 KB
Del
OK
BufferHandler.php
4.64 KB
Del
OK
ChromePHPHandler.php
5.1 KB
Del
OK
CouchDBHandler.php
1.96 KB
Del
OK
CubeHandler.php
5.29 KB
Del
OK
Curl
-
Del
OK
DeduplicationHandler.php
5.99 KB
Del
OK
DoctrineCouchDBHandler.php
1.24 KB
Del
OK
DynamoDbHandler.php
2.61 KB
Del
OK
ElasticaHandler.php
3.34 KB
Del
OK
ElasticsearchHandler.php
6.39 KB
Del
OK
ErrorLogHandler.php
2.63 KB
Del
OK
FallbackGroupHandler.php
1.75 KB
Del
OK
FilterHandler.php
6.86 KB
Del
OK
FingersCrossed
-
Del
OK
FingersCrossedHandler.php
8.46 KB
Del
OK
FirePHPHandler.php
5.15 KB
Del
OK
FleepHookHandler.php
3.42 KB
Del
OK
FlowdockHandler.php
3.5 KB
Del
OK
FormattableHandlerInterface.php
901 B
Del
OK
FormattableHandlerTrait.php
1.33 KB
Del
OK
GelfHandler.php
1.5 KB
Del
OK
GroupHandler.php
3.23 KB
Del
OK
Handler.php
1.24 KB
Del
OK
HandlerInterface.php
2.99 KB
Del
OK
HandlerWrapper.php
3.35 KB
Del
OK
IFTTTHandler.php
2.15 KB
Del
OK
InsightOpsHandler.php
1.9 KB
Del
OK
LogEntriesHandler.php
1.75 KB
Del
OK
LogglyHandler.php
4.1 KB
Del
OK
LogmaticHandler.php
2.57 KB
Del
OK
MailHandler.php
2.36 KB
Del
OK
MandrillHandler.php
2.48 KB
Del
OK
MissingExtensionException.php
502 B
Del
OK
MongoDBHandler.php
2.77 KB
Del
OK
NativeMailerHandler.php
4.92 KB
Del
OK
NewRelicHandler.php
6.14 KB
Del
OK
NoopHandler.php
910 B
Del
OK
NullHandler.php
1.39 KB
Del
OK
OverflowHandler.php
4.4 KB
Del
OK
PHPConsoleHandler.php
10.52 KB
Del
OK
ProcessHandler.php
5.07 KB
Del
OK
ProcessableHandlerInterface.php
1.22 KB
Del
OK
ProcessableHandlerTrait.php
1.77 KB
Del
OK
PsrHandler.php
2.49 KB
Del
OK
PushoverHandler.php
7.57 KB
Del
OK
RedisHandler.php
3.06 KB
Del
OK
RedisPubSubHandler.php
1.91 KB
Del
OK
RollbarHandler.php
3.26 KB
Del
OK
RotatingFileHandler.php
6.31 KB
Del
OK
SamplingHandler.php
4.29 KB
Del
OK
SendGridHandler.php
2.86 KB
Del
OK
Slack
-
Del
OK
SlackHandler.php
6.65 KB
Del
OK
SlackWebhookHandler.php
3.73 KB
Del
OK
SocketHandler.php
11.96 KB
Del
OK
SqsHandler.php
1.78 KB
Del
OK
StreamHandler.php
8.22 KB
Del
OK
SwiftMailerHandler.php
3.8 KB
Del
OK
SymfonyMailerHandler.php
3.63 KB
Del
OK
SyslogHandler.php
1.95 KB
Del
OK
SyslogUdp
-
Del
OK
SyslogUdpHandler.php
4.37 KB
Del
OK
TelegramBotHandler.php
8.08 KB
Del
OK
TestHandler.php
6.67 KB
Del
OK
WebRequestRecognizerTrait.php
553 B
Del
OK
WhatFailureGroupHandler.php
1.93 KB
Del
OK
ZendMonitorHandler.php
3.21 KB
Del
OK
Edit: RotatingFileHandler.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 InvalidArgumentException; use Google\Site_Kit_Dependencies\Monolog\Logger; use Google\Site_Kit_Dependencies\Monolog\Utils; /** * Stores logs to files that are rotated every day and a limited number of files are kept. * * This rotation is only intended to be used as a workaround. Using logrotate to * handle the rotation is strongly encouraged when you can use it. * * @author Christophe Coevoet <stof@notk.org> * @author Jordi Boggiano <j.boggiano@seld.be> */ class RotatingFileHandler extends StreamHandler { public const FILE_PER_DAY = 'Y-m-d'; public const FILE_PER_MONTH = 'Y-m'; public const FILE_PER_YEAR = 'Y'; /** @var string */ protected $filename; /** @var int */ protected $maxFiles; /** @var bool */ protected $mustRotate; /** @var \DateTimeImmutable */ protected $nextRotation; /** @var string */ protected $filenameFormat; /** @var string */ protected $dateFormat; /** * @param string $filename * @param int $maxFiles The maximal amount of files to keep (0 means unlimited) * @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 */ public function __construct(string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = \true, ?int $filePermission = null, bool $useLocking = \false) { $this->filename = Utils::canonicalizePath($filename); $this->maxFiles = $maxFiles; $this->nextRotation = new \DateTimeImmutable('tomorrow'); $this->filenameFormat = '{filename}-{date}'; $this->dateFormat = static::FILE_PER_DAY; parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission, $useLocking); } /** * {@inheritDoc} */ public function close(): void { parent::close(); if (\true === $this->mustRotate) { $this->rotate(); } } /** * {@inheritDoc} */ public function reset() { parent::reset(); if (\true === $this->mustRotate) { $this->rotate(); } } public function setFilenameFormat(string $filenameFormat, string $dateFormat): self { if (!preg_match('{^[Yy](([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) { throw new InvalidArgumentException('Invalid date format - format must be one of ' . 'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m") ' . 'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the ' . 'date formats using slashes, underscores and/or dots instead of dashes.'); } if (substr_count($filenameFormat, '{date}') === 0) { throw new InvalidArgumentException('Invalid filename format - format must contain at least `{date}`, because otherwise rotating is impossible.'); } $this->filenameFormat = $filenameFormat; $this->dateFormat = $dateFormat; $this->url = $this->getTimedFilename(); $this->close(); return $this; } /** * {@inheritDoc} */ protected function write(array $record): void { // on the first record written, if the log is new, we rotate (once per day) after the log has been written so that the new file exists if (null === $this->mustRotate) { $this->mustRotate = null === $this->url || !file_exists($this->url); } // if the next rotation is expired, then we rotate immediately if ($this->nextRotation <= $record['datetime']) { $this->mustRotate = \true; $this->close(); // triggers rotation } parent::write($record); if ($this->mustRotate) { $this->close(); // triggers rotation } } /** * Rotates the files. */ protected function rotate(): void { // update filename $this->url = $this->getTimedFilename(); $this->nextRotation = new \DateTimeImmutable('tomorrow'); $this->mustRotate = \false; // skip GC of old logs if files are unlimited if (0 === $this->maxFiles) { return; } $logFiles = glob($this->getGlobPattern()); if (\false === $logFiles) { // failed to glob return; } if ($this->maxFiles >= count($logFiles)) { // no files to remove return; } // Sorting the files by name to remove the older ones usort($logFiles, function ($a, $b) { return strcmp($b, $a); }); foreach (array_slice($logFiles, $this->maxFiles) as $file) { if (is_writable($file)) { // suppress errors here as unlink() might fail if two processes // are cleaning up/rotating at the same time set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool { return \true; }); unlink($file); restore_error_handler(); } } } protected function getTimedFilename(): string { $fileInfo = pathinfo($this->filename); $timedFilename = str_replace(['{filename}', '{date}'], [$fileInfo['filename'], date($this->dateFormat)], $fileInfo['dirname'] . '/' . $this->filenameFormat); if (isset($fileInfo['extension'])) { $timedFilename .= '.' . $fileInfo['extension']; } return $timedFilename; } protected function getGlobPattern(): string { $fileInfo = pathinfo($this->filename); $glob = str_replace(['{filename}', '{date}'], [$fileInfo['filename'], str_replace(['Y', 'y', 'm', 'd'], ['[0-9][0-9][0-9][0-9]', '[0-9][0-9]', '[0-9][0-9]', '[0-9][0-9]'], $this->dateFormat)], $fileInfo['dirname'] . '/' . $this->filenameFormat); if (isset($fileInfo['extension'])) { $glob .= '.' . $fileInfo['extension']; } return $glob; } }
Save