OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
monolog
/
monolog
/
src
/
Monolog
/
Handler
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:35:58 AM
rwxr-xr-x
📄
AbstractHandler.php
2.71 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
AbstractProcessingHandler.php
1.52 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
AbstractSyslogHandler.php
3.24 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
AmqpHandler.php
5.12 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
BrowserConsoleHandler.php
9.3 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
BufferHandler.php
4.6 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
ChromePHPHandler.php
5.21 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
CouchDBHandler.php
2.64 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
CubeHandler.php
5.48 KB
08/12/2024 10:35:56 AM
rw-r--r--
📁
Curl
-
08/12/2024 10:36:32 AM
rwxr-xr-x
📄
DeduplicationHandler.php
6.42 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
DoctrineCouchDBHandler.php
1.17 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
DynamoDbHandler.php
1.97 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
ElasticaHandler.php
3.72 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
ElasticsearchHandler.php
7.01 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
ErrorLogHandler.php
2.71 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
FallbackGroupHandler.php
1.75 KB
08/12/2024 10:35:56 AM
rw-r--r--
📄
FilterHandler.php
7.12 KB
08/12/2024 10:35:57 AM
rw-r--r--
📁
FingersCrossed
-
08/12/2024 10:36:32 AM
rwxr-xr-x
📄
FingersCrossedHandler.php
8.21 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
FirePHPHandler.php
5.2 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
FleepHookHandler.php
3.57 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
FlowdockHandler.php
3.52 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
FormattableHandlerInterface.php
791 bytes
08/12/2024 10:35:57 AM
rw-r--r--
📄
FormattableHandlerTrait.php
1.29 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
GelfHandler.php
1.48 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
GroupHandler.php
3.32 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
Handler.php
1.27 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
HandlerInterface.php
2.79 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
HandlerWrapper.php
3.41 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
IFTTTHandler.php
2.29 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
InsightOpsHandler.php
2.11 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
LogEntriesHandler.php
1.93 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
LogglyHandler.php
4.17 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
LogmaticHandler.php
2.67 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
MailHandler.php
2.28 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
MandrillHandler.php
2.56 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
MissingExtensionException.php
494 bytes
08/12/2024 10:35:57 AM
rw-r--r--
📄
MongoDBHandler.php
2.39 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
NativeMailerHandler.php
5.05 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
NewRelicHandler.php
5.88 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
NoopHandler.php
950 bytes
08/12/2024 10:35:57 AM
rw-r--r--
📄
NullHandler.php
1.35 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
OverflowHandler.php
4.35 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
PHPConsoleHandler.php
12.22 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
ProcessHandler.php
5.24 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
ProcessableHandlerInterface.php
1.2 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
ProcessableHandlerTrait.php
1.65 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
PsrHandler.php
2.5 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
PushoverHandler.php
8.16 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
RedisHandler.php
2.76 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
RedisPubSubHandler.php
1.71 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
RollbarHandler.php
3.65 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
RotatingFileHandler.php
7.02 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SamplingHandler.php
3.94 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SendGridHandler.php
2.97 KB
08/12/2024 10:35:57 AM
rw-r--r--
📁
Slack
-
08/12/2024 10:36:32 AM
rwxr-xr-x
📄
SlackHandler.php
7.25 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SlackWebhookHandler.php
3.92 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SocketHandler.php
12.27 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SqsHandler.php
1.77 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
StreamHandler.php
6.83 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SymfonyMailerHandler.php
3.55 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
SyslogHandler.php
1.71 KB
08/12/2024 10:35:57 AM
rw-r--r--
📁
SyslogUdp
-
08/12/2024 10:36:32 AM
rwxr-xr-x
📄
SyslogUdpHandler.php
4.78 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
TelegramBotHandler.php
9.51 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
TestHandler.php
6.51 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
WebRequestRecognizerTrait.php
527 bytes
08/12/2024 10:35:57 AM
rw-r--r--
📄
WhatFailureGroupHandler.php
1.94 KB
08/12/2024 10:35:57 AM
rw-r--r--
📄
ZendMonitorHandler.php
2.87 KB
08/12/2024 10:35:57 AM
rw-r--r--
Editing: DeduplicationHandler.php
Close
<?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 Psr\Log\LogLevel; use Monolog\LogRecord; /** * 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> */ class DeduplicationHandler extends BufferHandler { protected string $deduplicationStore; protected Level $deduplicationLevel; protected int $time; protected bool $gc = false; /** * @param HandlerInterface $handler Handler. * @param string|null $deduplicationStore The file/path where the deduplication log should be kept * @param int|string|Level|LogLevel::* $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 value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $deduplicationLevel */ public function __construct(HandlerInterface $handler, ?string $deduplicationStore = null, int|string|Level $deduplicationLevel = Level::Error, int $time = 60, bool $bubble = true) { parent::__construct($handler, 0, Level::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; } $store = null; if (file_exists($this->deduplicationStore)) { $store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } $passthru = null; foreach ($this->buffer as $record) { if ($record->level->value >= $this->deduplicationLevel->value) { $passthru = $passthru === true || !\is_array($store) || !$this->isDuplicate($store, $record); if ($passthru) { $line = $this->buildDeduplicationStoreEntry($record); file_put_contents($this->deduplicationStore, $line . "\n", FILE_APPEND); if (!\is_array($store)) { $store = []; } $store[] = $line; } } } // 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(); } } /** * If there is a store entry older than e.g. a day, this method should set `$this->gc` to `true` to trigger garbage collection. * @param string[] $store The deduplication store */ protected function isDuplicate(array $store, LogRecord $record): bool { $timestampValidity = $record->datetime->getTimestamp() - $this->time; $expectedMessage = preg_replace('{[\r\n].*}', '', $record->message); $yesterday = time() - 86400; for ($i = \count($store) - 1; $i >= 0; $i--) { list($timestamp, $level, $message) = explode(':', $store[$i], 3); if ($level === $record->level->getName() && $message === $expectedMessage && $timestamp > $timestampValidity) { return true; } if ($timestamp < $yesterday) { $this->gc = true; } } return false; } /** * @return string The given record serialized as a single line of text */ protected function buildDeduplicationStoreEntry(LogRecord $record): string { return $record->datetime->getTimestamp() . ':' . $record->level->getName() . ':' . preg_replace('{[\r\n].*}', '', $record->message); } private function collectLogs(): void { if (!file_exists($this->deduplicationStore)) { return; } $handle = fopen($this->deduplicationStore, 'rw+'); if (false === $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 (\is_string($log) && '' !== $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; } }