2022-10-17 21:25:03 +02:00
|
|
|
<?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\FingersCrossed;
|
|
|
|
|
|
|
|
use Monolog\Logger;
|
|
|
|
use Psr\Log\LogLevel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Error level based activation strategy.
|
|
|
|
*
|
|
|
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
2023-07-02 23:57:24 +02:00
|
|
|
*
|
|
|
|
* @phpstan-import-type Level from \Monolog\Logger
|
|
|
|
* @phpstan-import-type LevelName from \Monolog\Logger
|
2022-10-17 21:25:03 +02:00
|
|
|
*/
|
|
|
|
class ErrorLevelActivationStrategy implements ActivationStrategyInterface
|
|
|
|
{
|
2023-07-02 23:57:24 +02:00
|
|
|
/**
|
|
|
|
* @var Level
|
|
|
|
*/
|
|
|
|
private $actionLevel;
|
2022-10-17 21:25:03 +02:00
|
|
|
|
|
|
|
/**
|
2023-07-02 23:57:24 +02:00
|
|
|
* @param int|string $actionLevel Level or name or value
|
2022-10-17 21:25:03 +02:00
|
|
|
*
|
2023-07-02 23:57:24 +02:00
|
|
|
* @phpstan-param Level|LevelName|LogLevel::* $actionLevel
|
2022-10-17 21:25:03 +02:00
|
|
|
*/
|
2023-07-02 23:57:24 +02:00
|
|
|
public function __construct($actionLevel)
|
2022-10-17 21:25:03 +02:00
|
|
|
{
|
|
|
|
$this->actionLevel = Logger::toMonologLevel($actionLevel);
|
|
|
|
}
|
|
|
|
|
2023-07-02 23:57:24 +02:00
|
|
|
public function isHandlerActivated(array $record): bool
|
2022-10-17 21:25:03 +02:00
|
|
|
{
|
2023-07-02 23:57:24 +02:00
|
|
|
return $record['level'] >= $this->actionLevel;
|
2022-10-17 21:25:03 +02:00
|
|
|
}
|
|
|
|
}
|