/
home
/
techb158
/
immovalet.com
/
vendor
/
monolog
/
monolog
/
src
/
Monolog
/
Handler
/
/home/techb158/immovalet.com/vendor/monolog/monolog/src/Monolog/Handler
mkdir
upload
Name
Size
Mode
Actions
Curl/
-
0755
rm
FingersCrossed/
-
0755
rm
Slack/
-
0755
rm
SyslogUdp/
-
0755
rm
AbstractHandler.php
2651
0644
edit
dl
rm
AbstractProcessingHandler.php
1914
0644
edit
dl
rm
AbstractSyslogHandler.php
3540
0644
edit
dl
rm
AmqpHandler.php
3940
0644
edit
dl
rm
BrowserConsoleHandler.php
8382
0644
edit
dl
rm
BufferHandler.php
4644
0644
edit
dl
rm
ChromePHPHandler.php
5229
0644
edit
dl
rm
CouchDBHandler.php
2103
0644
edit
dl
rm
CubeHandler.php
5285
0644
edit
dl
rm
DeduplicationHandler.php
6063
0644
edit
dl
rm
DoctrineCouchDBHandler.php
1128
0644
edit
dl
rm
DynamoDbHandler.php
2482
0644
edit
dl
rm
ElasticaHandler.php
3328
0644
edit
dl
rm
ElasticsearchHandler.php
5297
0644
edit
dl
rm
ErrorLogHandler.php
2587
0644
edit
dl
rm
FallbackGroupHandler.php
1761
0644
edit
dl
rm
FilterHandler.php
6843
0644
edit
dl
rm
FingersCrossedHandler.php
8469
0644
edit
dl
rm
FirePHPHandler.php
5288
0644
edit
dl
rm
FleepHookHandler.php
3213
0644
edit
dl
rm
FlowdockHandler.php
3138
0644
edit
dl
rm
FormattableHandlerInterface.php
845
0644
edit
dl
rm
FormattableHandlerTrait.php
1281
0644
edit
dl
rm
GelfHandler.php
1399
0644
edit
dl
rm
GroupHandler.php
3234
0644
edit
dl
rm
Handler.php
1029
0644
edit
dl
rm
HandlerInterface.php
3032
0644
edit
dl
rm
HandlerWrapper.php
3358
0644
edit
dl
rm
IFTTTHandler.php
2026
0644
edit
dl
rm
InsightOpsHandler.php
1710
0644
edit
dl
rm
LogEntriesHandler.php
1529
0644
edit
dl
rm
LogglyHandler.php
4098
0644
edit
dl
rm
LogmaticHandler.php
2312
0644
edit
dl
rm
MailHandler.php
2341
0644
edit
dl
rm
MandrillHandler.php
2473
0644
edit
dl
rm
MissingExtensionException.php
473
0644
edit
dl
rm
MongoDBHandler.php
2545
0644
edit
dl
rm
NativeMailerHandler.php
4971
0644
edit
dl
rm
NewRelicHandler.php
6211
0644
edit
dl
rm
NoopHandler.php
880
0644
edit
dl
rm
NullHandler.php
1337
0644
edit
dl
rm
OverflowHandler.php
4533
0644
edit
dl
rm
PHPConsoleHandler.php
10472
0644
edit
dl
rm
ProcessableHandlerInterface.php
1197
0644
edit
dl
rm
ProcessableHandlerTrait.php
1737
0644
edit
dl
rm
ProcessHandler.php
5215
0644
edit
dl
rm
PsrHandler.php
2440
0644
edit
dl
rm
PushoverHandler.php
7731
0644
edit
dl
rm
RedisHandler.php
2988
0644
edit
dl
rm
RedisPubSubHandler.php
1788
0644
edit
dl
rm
RollbarHandler.php
3412
0644
edit
dl
rm
RotatingFileHandler.php
6230
0644
edit
dl
rm
SamplingHandler.php
4338
0644
edit
dl
rm
SendGridHandler.php
2711
0644
edit
dl
rm
SlackHandler.php
6666
0644
edit
dl
rm
SlackWebhookHandler.php
3759
0644
edit
dl
rm
SocketHandler.php
10866
0644
edit
dl
rm
SqsHandler.php
1699
0644
edit
dl
rm
StreamHandler.php
5808
0644
edit
dl
rm
SwiftMailerHandler.php
3342
0644
edit
dl
rm
SyslogHandler.php
1841
0644
edit
dl
rm
SyslogUdpHandler.php
4287
0644
edit
dl
rm
TelegramBotHandler.php
5515
0644
edit
dl
rm
TestHandler.php
6750
0644
edit
dl
rm
WebRequestRecognizerTrait.php
524
0644
edit
dl
rm
WhatFailureGroupHandler.php
1669
0644
edit
dl
rm
ZendMonitorHandler.php
3137
0644
edit
dl
rm
Edit:
/home/techb158/immovalet.com/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php
(6063B)
<?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\Logger; use Psr\Log\LogLevel; /** * Simple handler wrapper that deduplicates log records across multiple requests * * It also includes the BufferHandler functionality and will buffer * all messages until the end of the request or flush() is called. * * This works by storing all log records' messages above $deduplicationLevel * to the file specified by $deduplicationStore. When further logs come in at the end of the * request (or when flush() is called), all those above $deduplicationLevel are checked * against the existing stored logs. If they match and the timestamps in the stored log is * not older than $time seconds, the new log record is discarded. If no log record is new, the * whole data set is discarded. * * This is mainly useful in combination with Mail handlers or things like Slack or HipChat handlers * that send messages to people, to avoid spamming with the same message over and over in case of * a major component failure like a database server being down which makes all requests fail in the * same way. * * @author Jordi Boggiano <j.boggiano@seld.be> * * @phpstan-import-type Record from \Monolog\Logger * @phpstan-import-type LevelName from \Monolog\Logger * @phpstan-import-type Level from \Monolog\Logger */ class DeduplicationHandler extends BufferHandler { /** * @var string */ protected $deduplicationStore; /** * @var Level */ protected $deduplicationLevel; /** * @var int */ protected $time; /** * @var bool */ private $gc = false; /** * @param HandlerInterface $handler Handler. * @param string $deduplicationStore The file/path where the deduplication log should be kept * @param string|int $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes * @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * * @phpstan-param Level|LevelName|LogLevel::* $deduplicationLevel */ public function __construct(HandlerInterface $handler, ?string $deduplicationStore = null, $deduplicationLevel = Logger::ERROR, int $time = 60, bool $bubble = true) { parent::__construct($handler, 0, Logger::DEBUG, $bubble, false); $this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore; $this->deduplicationLevel = Logger::toMonologLevel($deduplicationLevel); $this->time = $time; } public function flush(): void { if ($this->bufferSize === 0) { return; } $passthru = null; foreach ($this->buffer as $record) { if ($record['level'] >= $this->deduplicationLevel) { $passthru = $passthru || !$this->isDuplicate($record); if ($passthru) { $this->appendRecord($record); } } } // default of null is valid as well as if no record matches duplicationLevel we just pass through if ($passthru === true || $passthru === null) { $this->handler->handleBatch($this->buffer); } $this->clear(); if ($this->gc) { $this->collectLogs(); } } /** * @phpstan-param Record $record */ private function isDuplicate(array $record): bool { if (!file_exists($this->deduplicationStore)) { return false; } $store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (!is_array($store)) { return false; } $yesterday = time() - 86400; $timestampValidity = $record['datetime']->getTimestamp() - $this->time; $expectedMessage = preg_replace('{[\r\n].*}', '', $record['message']); for ($i = count($store) - 1; $i >= 0; $i--) { list($timestamp, $level, $message) = explode(':', $store[$i], 3); if ($level === $record['level_name'] && $message === $expectedMessage && $timestamp > $timestampValidity) { return true; } if ($timestamp < $yesterday) { $this->gc = true; } } return false; } private function collectLogs(): void { if (!file_exists($this->deduplicationStore)) { return; } $handle = fopen($this->deduplicationStore, 'rw+'); if (!$handle) { throw new \RuntimeException('Failed to open file for reading and writing: ' . $this->deduplicationStore); } flock($handle, LOCK_EX); $validLogs = []; $timestampValidity = time() - $this->time; while (!feof($handle)) { $log = fgets($handle); if ($log && substr($log, 0, 10) >= $timestampValidity) { $validLogs[] = $log; } } ftruncate($handle, 0); rewind($handle); foreach ($validLogs as $log) { fwrite($handle, $log); } flock($handle, LOCK_UN); fclose($handle); $this->gc = false; } /** * @phpstan-param Record $record */ private function appendRecord(array $record): void { file_put_contents($this->deduplicationStore, $record['datetime']->getTimestamp() . ':' . $record['level_name'] . ':' . preg_replace('{[\r\n].*}', '', $record['message']) . "\n", FILE_APPEND); } }
Save
cmd:
run