update
This commit is contained in:
60
projects/priceservice/vendor/symfony/monolog-bridge/Processor/AbstractTokenProcessor.php
vendored
Normal file
60
projects/priceservice/vendor/symfony/monolog-bridge/Processor/AbstractTokenProcessor.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Monolog\LogRecord;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* The base class for security token processors.
|
||||
*
|
||||
* @author Dany Maillard <danymaillard93b@gmail.com>
|
||||
* @author Igor Timoshenko <igor.timoshenko@i.ua>
|
||||
*
|
||||
* @internal since Symfony 6.1
|
||||
*/
|
||||
abstract class AbstractTokenProcessor
|
||||
{
|
||||
use CompatibilityProcessor;
|
||||
|
||||
/**
|
||||
* @var TokenStorageInterface
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
public function __construct(TokenStorageInterface $tokenStorage)
|
||||
{
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
}
|
||||
|
||||
abstract protected function getKey(): string;
|
||||
|
||||
abstract protected function getToken(): ?TokenInterface;
|
||||
|
||||
private function doInvoke(array|LogRecord $record): array|LogRecord
|
||||
{
|
||||
$record['extra'][$this->getKey()] = null;
|
||||
|
||||
if (null !== $token = $this->getToken()) {
|
||||
$record['extra'][$this->getKey()] = [
|
||||
'authenticated' => (bool) $token->getUser(),
|
||||
'roles' => $token->getRoleNames(),
|
||||
];
|
||||
|
||||
// @deprecated since Symfony 5.3, change to $token->getUserIdentifier() in 7.0
|
||||
$record['extra'][$this->getKey()]['user_identifier'] = method_exists($token, 'getUserIdentifier') ? $token->getUserIdentifier() : $token->getUsername();
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
51
projects/priceservice/vendor/symfony/monolog-bridge/Processor/CompatibilityProcessor.php
vendored
Normal file
51
projects/priceservice/vendor/symfony/monolog-bridge/Processor/CompatibilityProcessor.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\LogRecord;
|
||||
|
||||
if (Logger::API >= 3) {
|
||||
/**
|
||||
* The base class for compatibility between Monolog 3 LogRecord and Monolog 1/2 array records.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait CompatibilityProcessor
|
||||
{
|
||||
abstract private function doInvoke(array|LogRecord $record): array|LogRecord;
|
||||
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
return $this->doInvoke($record);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* The base class for compatibility between Monolog 3 LogRecord and Monolog 1/2 array records.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait CompatibilityProcessor
|
||||
{
|
||||
abstract private function doInvoke(array|LogRecord $record): array|LogRecord;
|
||||
|
||||
public function __invoke(array $record): array
|
||||
{
|
||||
return $this->doInvoke($record);
|
||||
}
|
||||
}
|
||||
}
|
||||
80
projects/priceservice/vendor/symfony/monolog-bridge/Processor/ConsoleCommandProcessor.php
vendored
Normal file
80
projects/priceservice/vendor/symfony/monolog-bridge/Processor/ConsoleCommandProcessor.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Monolog\LogRecord;
|
||||
use Symfony\Component\Console\ConsoleEvents;
|
||||
use Symfony\Component\Console\Event\ConsoleEvent;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
/**
|
||||
* Adds the current console command information to the log entry.
|
||||
*
|
||||
* @author Piotr Stankowski <git@trakos.pl>
|
||||
*
|
||||
* @final since Symfony 6.1
|
||||
*/
|
||||
class ConsoleCommandProcessor implements EventSubscriberInterface, ResetInterface
|
||||
{
|
||||
use CompatibilityProcessor;
|
||||
|
||||
private array $commandData;
|
||||
private bool $includeArguments;
|
||||
private bool $includeOptions;
|
||||
|
||||
public function __construct(bool $includeArguments = true, bool $includeOptions = false)
|
||||
{
|
||||
$this->includeArguments = $includeArguments;
|
||||
$this->includeOptions = $includeOptions;
|
||||
}
|
||||
|
||||
private function doInvoke(array|LogRecord $record): array|LogRecord
|
||||
{
|
||||
if (isset($this->commandData) && !isset($record['extra']['command'])) {
|
||||
$record['extra']['command'] = $this->commandData;
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
unset($this->commandData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addCommandData(ConsoleEvent $event)
|
||||
{
|
||||
$this->commandData = [
|
||||
'name' => $event->getCommand()->getName(),
|
||||
];
|
||||
if ($this->includeArguments) {
|
||||
$this->commandData['arguments'] = $event->getInput()->getArguments();
|
||||
}
|
||||
if ($this->includeOptions) {
|
||||
$this->commandData['options'] = $event->getInput()->getOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
ConsoleEvents::COMMAND => ['addCommandData', 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
106
projects/priceservice/vendor/symfony/monolog-bridge/Processor/DebugProcessor.php
vendored
Normal file
106
projects/priceservice/vendor/symfony/monolog-bridge/Processor/DebugProcessor.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\LogRecord;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
class DebugProcessor implements DebugLoggerInterface, ResetInterface
|
||||
{
|
||||
use CompatibilityProcessor;
|
||||
|
||||
private array $records = [];
|
||||
private array $errorCount = [];
|
||||
private ?RequestStack $requestStack;
|
||||
|
||||
public function __construct(?RequestStack $requestStack = null)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
private function doInvoke(array|LogRecord $record): array|LogRecord
|
||||
{
|
||||
$key = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_id($request) : '';
|
||||
|
||||
$timestampRfc3339 = false;
|
||||
if ($record['datetime'] instanceof \DateTimeInterface) {
|
||||
$timestamp = $record['datetime']->getTimestamp();
|
||||
$timestampRfc3339 = $record['datetime']->format(\DateTimeInterface::RFC3339_EXTENDED);
|
||||
} elseif (false !== $timestamp = strtotime($record['datetime'])) {
|
||||
$timestampRfc3339 = (new \DateTimeImmutable($record['datetime']))->format(\DateTimeInterface::RFC3339_EXTENDED);
|
||||
}
|
||||
|
||||
$this->records[$key][] = [
|
||||
'timestamp' => $timestamp,
|
||||
'timestamp_rfc3339' => $timestampRfc3339,
|
||||
'message' => $record['message'],
|
||||
'priority' => $record['level'],
|
||||
'priorityName' => $record['level_name'],
|
||||
'context' => $record['context'],
|
||||
'channel' => $record['channel'] ?? '',
|
||||
];
|
||||
|
||||
if (!isset($this->errorCount[$key])) {
|
||||
$this->errorCount[$key] = 0;
|
||||
}
|
||||
|
||||
switch ($record['level']) {
|
||||
case Logger::ERROR:
|
||||
case Logger::CRITICAL:
|
||||
case Logger::ALERT:
|
||||
case Logger::EMERGENCY:
|
||||
++$this->errorCount[$key];
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
public function getLogs(?Request $request = null): array
|
||||
{
|
||||
if (null !== $request) {
|
||||
return $this->records[spl_object_id($request)] ?? [];
|
||||
}
|
||||
|
||||
if (0 === \count($this->records)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_merge(...array_values($this->records));
|
||||
}
|
||||
|
||||
public function countErrors(?Request $request = null): int
|
||||
{
|
||||
if (null !== $request) {
|
||||
return $this->errorCount[spl_object_id($request)] ?? 0;
|
||||
}
|
||||
|
||||
return array_sum($this->errorCount);
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->records = [];
|
||||
$this->errorCount = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->clear();
|
||||
}
|
||||
}
|
||||
89
projects/priceservice/vendor/symfony/monolog-bridge/Processor/RouteProcessor.php
vendored
Normal file
89
projects/priceservice/vendor/symfony/monolog-bridge/Processor/RouteProcessor.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Monolog\LogRecord;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
/**
|
||||
* Adds the current route information to the log entry.
|
||||
*
|
||||
* @author Piotr Stankowski <git@trakos.pl>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class RouteProcessor implements EventSubscriberInterface, ResetInterface
|
||||
{
|
||||
private array $routeData = [];
|
||||
private bool $includeParams;
|
||||
|
||||
public function __construct(bool $includeParams = true)
|
||||
{
|
||||
$this->includeParams = $includeParams;
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
public function __invoke(array|LogRecord $record): array|LogRecord
|
||||
{
|
||||
if ($this->routeData && !isset($record['extra']['requests'])) {
|
||||
$record['extra']['requests'] = array_values($this->routeData);
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
$this->routeData = [];
|
||||
}
|
||||
|
||||
public function addRouteData(RequestEvent $event): void
|
||||
{
|
||||
if ($event->isMainRequest()) {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
$request = $event->getRequest();
|
||||
if (!$request->attributes->has('_controller')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$currentRequestData = [
|
||||
'controller' => $request->attributes->get('_controller'),
|
||||
'route' => $request->attributes->get('_route'),
|
||||
];
|
||||
|
||||
if ($this->includeParams) {
|
||||
$currentRequestData['route_params'] = $request->attributes->get('_route_params');
|
||||
}
|
||||
|
||||
$this->routeData[spl_object_id($request)] = $currentRequestData;
|
||||
}
|
||||
|
||||
public function removeRouteData(FinishRequestEvent $event): void
|
||||
{
|
||||
$requestId = spl_object_id($event->getRequest());
|
||||
unset($this->routeData[$requestId]);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
KernelEvents::REQUEST => ['addRouteData', 1],
|
||||
KernelEvents::FINISH_REQUEST => ['removeRouteData', 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
41
projects/priceservice/vendor/symfony/monolog-bridge/Processor/SwitchUserTokenProcessor.php
vendored
Normal file
41
projects/priceservice/vendor/symfony/monolog-bridge/Processor/SwitchUserTokenProcessor.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* Adds the original security token to the log entry.
|
||||
*
|
||||
* @author Igor Timoshenko <igor.timoshenko@i.ua>
|
||||
*
|
||||
* @final since Symfony 6.1
|
||||
*/
|
||||
class SwitchUserTokenProcessor extends AbstractTokenProcessor
|
||||
{
|
||||
protected function getKey(): string
|
||||
{
|
||||
return 'impersonator_token';
|
||||
}
|
||||
|
||||
protected function getToken(): ?TokenInterface
|
||||
{
|
||||
$token = $this->tokenStorage->getToken();
|
||||
|
||||
if ($token instanceof SwitchUserToken) {
|
||||
return $token->getOriginalToken();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
35
projects/priceservice/vendor/symfony/monolog-bridge/Processor/TokenProcessor.php
vendored
Normal file
35
projects/priceservice/vendor/symfony/monolog-bridge/Processor/TokenProcessor.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* Adds the current security token to the log entry.
|
||||
*
|
||||
* @author Dany Maillard <danymaillard93b@gmail.com>
|
||||
* @author Igor Timoshenko <igor.timoshenko@i.ua>
|
||||
*
|
||||
* @final since Symfony 6.1
|
||||
*/
|
||||
class TokenProcessor extends AbstractTokenProcessor
|
||||
{
|
||||
protected function getKey(): string
|
||||
{
|
||||
return 'token';
|
||||
}
|
||||
|
||||
protected function getToken(): ?TokenInterface
|
||||
{
|
||||
return $this->tokenStorage->getToken();
|
||||
}
|
||||
}
|
||||
48
projects/priceservice/vendor/symfony/monolog-bridge/Processor/WebProcessor.php
vendored
Normal file
48
projects/priceservice/vendor/symfony/monolog-bridge/Processor/WebProcessor.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Monolog\Processor;
|
||||
|
||||
use Monolog\Processor\WebProcessor as BaseWebProcessor;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* WebProcessor override to read from the HttpFoundation's Request.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(?array $extraFields = null)
|
||||
{
|
||||
// Pass an empty array as the default null value would access $_SERVER
|
||||
parent::__construct([], $extraFields);
|
||||
}
|
||||
|
||||
public function onKernelRequest(RequestEvent $event): void
|
||||
{
|
||||
if ($event->isMainRequest()) {
|
||||
$this->serverData = $event->getRequest()->server->all();
|
||||
$this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
KernelEvents::REQUEST => ['onKernelRequest', 4096],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user