mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 12:47:39 +02:00
Improve build
This commit is contained in:
27
.github/workflows/continuous-integration.yml
vendored
27
.github/workflows/continuous-integration.yml
vendored
@@ -22,16 +22,35 @@ jobs:
|
|||||||
- "8.0"
|
- "8.0"
|
||||||
# disabled for now as phpspec/prophecy does not allow 8.1
|
# disabled for now as phpspec/prophecy does not allow 8.1
|
||||||
# - "8.1"
|
# - "8.1"
|
||||||
|
dependencies: [highest]
|
||||||
|
include:
|
||||||
|
- php-version: "7.2"
|
||||||
|
dependencies: lowest
|
||||||
|
- php-version: "8.0"
|
||||||
|
dependencies: lowest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
uses: "actions/checkout@v2"
|
uses: "actions/checkout@v2"
|
||||||
|
|
||||||
- name: "Install PHP 7+"
|
- name: "Install PHP"
|
||||||
uses: "shivammathur/setup-php@v2"
|
uses: "shivammathur/setup-php@v2"
|
||||||
with:
|
with:
|
||||||
coverage: "none"
|
coverage: "none"
|
||||||
php-version: "${{ matrix.php-version }}"
|
php-version: "${{ matrix.php-version }}"
|
||||||
|
extensions: mongodb, redis, amqp
|
||||||
|
|
||||||
|
- name: Configure sysctl limits
|
||||||
|
run: |
|
||||||
|
sudo swapoff -a
|
||||||
|
sudo sysctl -w vm.swappiness=1
|
||||||
|
sudo sysctl -w fs.file-max=262144
|
||||||
|
sudo sysctl -w vm.max_map_count=262144
|
||||||
|
|
||||||
|
- name: Runs Elasticsearch
|
||||||
|
uses: elastic/elastic-github-actions/elasticsearch@master
|
||||||
|
with:
|
||||||
|
stack-version: 7.6.0
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composercache
|
id: composercache
|
||||||
@@ -44,9 +63,13 @@ jobs:
|
|||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
|
||||||
|
- name: "Handle lowest dependencies update"
|
||||||
|
if: "contains(matrix.dependencies, 'lowest')"
|
||||||
|
run: "echo \"COMPOSER_FLAGS=$COMPOSER_FLAGS --prefer-lowest\" >> $GITHUB_ENV"
|
||||||
|
|
||||||
- name: "Install latest dependencies"
|
- name: "Install latest dependencies"
|
||||||
run: |
|
run: |
|
||||||
composer update ${{ env.COMPOSER_FLAGS }}
|
composer update ${{ env.COMPOSER_FLAGS }}
|
||||||
|
|
||||||
- name: "Run tests"
|
- name: "Run tests"
|
||||||
run: "composer test"
|
run: "composer exec phpunit -- --verbose"
|
||||||
|
@@ -1,16 +1,19 @@
|
|||||||
parameters:
|
parameters:
|
||||||
level: 3
|
level: 5
|
||||||
|
|
||||||
|
treatPhpDocTypesAsCertain: false
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
- src/
|
- src/
|
||||||
# - tests/
|
# - tests/
|
||||||
|
|
||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- '#zend_monitor_|ZEND_MONITOR_#'
|
- '#zend_monitor_|ZEND_MONITOR_#'
|
||||||
- '#RollbarNotifier#'
|
|
||||||
- '#Predis\\Client#'
|
|
||||||
- '#^Cannot call method ltrim\(\) on int\|false.$#'
|
- '#^Cannot call method ltrim\(\) on int\|false.$#'
|
||||||
- '#^Access to an undefined property Raven_Client::\$context.$#'
|
|
||||||
- '#MongoDB\\(Client|Collection)#'
|
- '#MongoDB\\(Client|Collection)#'
|
||||||
- '#Gelf\\IMessagePublisher#'
|
- message: '#Return type \(string\) of method Monolog\\Formatter\\LineFormatter::normalizeException\(\) should be compatible with return type \(array\) of method Monolog\\Formatter\\NormalizerFormatter::normalizeException\(\)#'
|
||||||
|
paths:
|
||||||
|
- src/Monolog/Formatter/LineFormatter.php
|
||||||
|
- message: '#Method Monolog\\Handler\\LogglyHandler::loadCurlHandle\(\) never returns resource so it can be removed from the return typehint.#'
|
||||||
|
paths:
|
||||||
|
- src/Monolog/Handler/LogglyHandler.php
|
||||||
|
@@ -58,6 +58,7 @@ class ErrorHandler
|
|||||||
*/
|
*/
|
||||||
public static function register(LoggerInterface $logger, $errorLevelMap = [], $exceptionLevelMap = [], $fatalLevel = null): self
|
public static function register(LoggerInterface $logger, $errorLevelMap = [], $exceptionLevelMap = [], $fatalLevel = null): self
|
||||||
{
|
{
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$handler = new static($logger);
|
$handler = new static($logger);
|
||||||
if ($errorLevelMap !== false) {
|
if ($errorLevelMap !== false) {
|
||||||
$handler->registerErrorHandler($errorLevelMap);
|
$handler->registerErrorHandler($errorLevelMap);
|
||||||
@@ -74,7 +75,9 @@ class ErrorHandler
|
|||||||
|
|
||||||
public function registerExceptionHandler($levelMap = [], $callPrevious = true): self
|
public function registerExceptionHandler($levelMap = [], $callPrevious = true): self
|
||||||
{
|
{
|
||||||
$prev = set_exception_handler([$this, 'handleException']);
|
$prev = set_exception_handler(function (\Throwable $e): void {
|
||||||
|
$this->handleException($e);
|
||||||
|
});
|
||||||
$this->uncaughtExceptionLevelMap = $levelMap;
|
$this->uncaughtExceptionLevelMap = $levelMap;
|
||||||
foreach ($this->defaultExceptionLevelMap() as $class => $level) {
|
foreach ($this->defaultExceptionLevelMap() as $class => $level) {
|
||||||
if (!isset($this->uncaughtExceptionLevelMap[$class])) {
|
if (!isset($this->uncaughtExceptionLevelMap[$class])) {
|
||||||
@@ -145,11 +148,7 @@ class ErrorHandler
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function handleException(\Throwable $e)
|
||||||
* @private
|
|
||||||
* @param \Exception $e
|
|
||||||
*/
|
|
||||||
public function handleException($e)
|
|
||||||
{
|
{
|
||||||
$level = LogLevel::ERROR;
|
$level = LogLevel::ERROR;
|
||||||
foreach ($this->uncaughtExceptionLevelMap as $class => $candidate) {
|
foreach ($this->uncaughtExceptionLevelMap as $class => $candidate) {
|
||||||
|
@@ -134,6 +134,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
|||||||
$message->setAdditional($this->contextPrefix . $key, $val);
|
$message->setAdditional($this->contextPrefix . $key, $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
if (null === $message->getFile() && isset($record['context']['exception']['file'])) {
|
if (null === $message->getFile() && isset($record['context']['exception']['file'])) {
|
||||||
if (preg_match("/^(.+):([0-9]+)$/", $record['context']['exception']['file'], $matches)) {
|
if (preg_match("/^(.+):([0-9]+)$/", $record['context']['exception']['file'], $matches)) {
|
||||||
$message->setFile($matches[1]);
|
$message->setFile($matches[1]);
|
||||||
|
@@ -63,8 +63,6 @@ class JsonFormatter extends NormalizerFormatter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @suppress PhanTypeComparisonToArray
|
|
||||||
*/
|
*/
|
||||||
public function format(array $record): string
|
public function format(array $record): string
|
||||||
{
|
{
|
||||||
|
@@ -126,9 +126,6 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
return $this->replaceNewlines($this->convertToString($value));
|
return $this->replaceNewlines($this->convertToString($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @suppress PhanParamSignatureMismatch
|
|
||||||
*/
|
|
||||||
protected function normalizeException(\Throwable $e, int $depth = 0): string
|
protected function normalizeException(\Throwable $e, int $depth = 0): string
|
||||||
{
|
{
|
||||||
$str = $this->formatException($e);
|
$str = $this->formatException($e);
|
||||||
|
@@ -118,7 +118,7 @@ class MongoDBFormatter implements FormatterInterface
|
|||||||
|
|
||||||
private function getMongoDbDateTime(\DateTimeInterface $value): UTCDateTime
|
private function getMongoDbDateTime(\DateTimeInterface $value): UTCDateTime
|
||||||
{
|
{
|
||||||
return new UTCDateTime((int) (string) floor($value->format('U.u') * 1000));
|
return new UTCDateTime((int) floor(((float) $value->format('U.u')) * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +130,7 @@ class MongoDBFormatter implements FormatterInterface
|
|||||||
*/
|
*/
|
||||||
private function legacyGetMongoDbDateTime(\DateTimeInterface $value): UTCDateTime
|
private function legacyGetMongoDbDateTime(\DateTimeInterface $value): UTCDateTime
|
||||||
{
|
{
|
||||||
$milliseconds = floor($value->format('U.u') * 1000);
|
$milliseconds = floor(((float) $value->format('U.u')) * 1000);
|
||||||
|
|
||||||
$milliseconds = (PHP_INT_SIZE == 8) //64-bit OS?
|
$milliseconds = (PHP_INT_SIZE == 8) //64-bit OS?
|
||||||
? (int) $milliseconds
|
? (int) $milliseconds
|
||||||
|
@@ -24,10 +24,14 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
{
|
{
|
||||||
public const SIMPLE_DATE = "Y-m-d\TH:i:sP";
|
public const SIMPLE_DATE = "Y-m-d\TH:i:sP";
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
protected $dateFormat;
|
protected $dateFormat;
|
||||||
|
/** @var int */
|
||||||
protected $maxNormalizeDepth = 9;
|
protected $maxNormalizeDepth = 9;
|
||||||
|
/** @var int */
|
||||||
protected $maxNormalizeItemCount = 1000;
|
protected $maxNormalizeItemCount = 1000;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
private $jsonEncodeOptions = Utils::DEFAULT_JSON_FLAGS;
|
private $jsonEncodeOptions = Utils::DEFAULT_JSON_FLAGS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,12 +163,7 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
$value = $data->__toString();
|
$value = $data->__toString();
|
||||||
} else {
|
} else {
|
||||||
// the rest is normalized by json encoding and decoding it
|
// the rest is normalized by json encoding and decoding it
|
||||||
$encoded = $this->toJson($data, true);
|
$value = json_decode($this->toJson($data, true), true);
|
||||||
if ($encoded === false) {
|
|
||||||
$value = 'JSON_ERROR';
|
|
||||||
} else {
|
|
||||||
$value = json_decode($encoded, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [Utils::getClass($data) => $value];
|
return [Utils::getClass($data) => $value];
|
||||||
@@ -248,12 +247,12 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
return $date->format($this->dateFormat);
|
return $date->format($this->dateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addJsonEncodeOption($option)
|
public function addJsonEncodeOption(int $option)
|
||||||
{
|
{
|
||||||
$this->jsonEncodeOptions |= $option;
|
$this->jsonEncodeOptions |= $option;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeJsonEncodeOption($option)
|
public function removeJsonEncodeOption(int $option)
|
||||||
{
|
{
|
||||||
$this->jsonEncodeOptions &= ~$option;
|
$this->jsonEncodeOptions &= ~$option;
|
||||||
}
|
}
|
||||||
|
@@ -33,13 +33,13 @@ class ScalarFormatter extends NormalizerFormatter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return mixed
|
* @return string|int|bool|null
|
||||||
*/
|
*/
|
||||||
protected function normalizeValue($value)
|
protected function normalizeValue($value)
|
||||||
{
|
{
|
||||||
$normalized = $this->normalize($value);
|
$normalized = $this->normalize($value);
|
||||||
|
|
||||||
if (is_array($normalized) || is_object($normalized)) {
|
if (is_array($normalized)) {
|
||||||
return $this->toJson($normalized, true);
|
return $this->toJson($normalized, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ class WildfireFormatter extends NormalizerFormatter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @suppress PhanTypeMismatchReturn
|
* @return int|bool|string|null|array|object
|
||||||
*/
|
*/
|
||||||
protected function normalize($data, int $depth = 0)
|
protected function normalize($data, int $depth = 0)
|
||||||
{
|
{
|
||||||
|
@@ -53,6 +53,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
public function __construct(DynamoDbClient $client, string $table, $level = Logger::DEBUG, bool $bubble = true)
|
public function __construct(DynamoDbClient $client, string $table, $level = Logger::DEBUG, bool $bubble = true)
|
||||||
{
|
{
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
if (defined('Aws\Sdk::VERSION') && version_compare(Sdk::VERSION, '3.0', '>=')) {
|
if (defined('Aws\Sdk::VERSION') && version_compare(Sdk::VERSION, '3.0', '>=')) {
|
||||||
$this->version = 3;
|
$this->version = 3;
|
||||||
$this->marshaler = new Marshaler;
|
$this->marshaler = new Marshaler;
|
||||||
|
@@ -159,17 +159,27 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
|
|||||||
*/
|
*/
|
||||||
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
||||||
{
|
{
|
||||||
$this->getHandler()->setFormatter($formatter);
|
$handler = $this->getHandler();
|
||||||
|
if ($handler instanceof FormattableHandlerInterface) {
|
||||||
|
$handler->setFormatter($formatter);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getFormatter(): FormatterInterface
|
public function getFormatter(): FormatterInterface
|
||||||
{
|
{
|
||||||
return $this->getHandler()->getFormatter();
|
$handler = $this->getHandler();
|
||||||
|
if ($handler instanceof FormattableHandlerInterface) {
|
||||||
|
return $handler->getFormatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset()
|
public function reset()
|
||||||
|
@@ -202,16 +202,26 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
|
|||||||
*/
|
*/
|
||||||
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
||||||
{
|
{
|
||||||
$this->getHandler()->setFormatter($formatter);
|
$handler = $this->getHandler();
|
||||||
|
if ($handler instanceof FormattableHandlerInterface) {
|
||||||
|
$handler->setFormatter($formatter);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getFormatter(): FormatterInterface
|
public function getFormatter(): FormatterInterface
|
||||||
{
|
{
|
||||||
return $this->getHandler()->getFormatter();
|
$handler = $this->getHandler();
|
||||||
|
if ($handler instanceof FormattableHandlerInterface) {
|
||||||
|
return $handler->getFormatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,13 +22,12 @@ use Monolog\Formatter\LineFormatter;
|
|||||||
trait FormattableHandlerTrait
|
trait FormattableHandlerTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var FormatterInterface
|
* @var ?FormatterInterface
|
||||||
*/
|
*/
|
||||||
protected $formatter;
|
protected $formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @suppress PhanTypeMismatchReturn
|
|
||||||
*/
|
*/
|
||||||
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
||||||
{
|
{
|
||||||
|
@@ -128,7 +128,7 @@ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, F
|
|||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
if ($this->handler instanceof ResettableInterface) {
|
if ($this->handler instanceof ResettableInterface) {
|
||||||
return $this->handler->reset();
|
$this->handler->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,7 @@ class LogglyHandler extends AbstractProcessingHandler
|
|||||||
protected function getCurlHandler(string $endpoint)
|
protected function getCurlHandler(string $endpoint)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($endpoint, $this->curlHandlers)) {
|
if (!array_key_exists($endpoint, $this->curlHandlers)) {
|
||||||
$this->curlHandlers[$endpoint] = $this->loadCurlHandler($endpoint);
|
$this->curlHandlers[$endpoint] = $this->loadCurlHandle($endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->curlHandlers[$endpoint];
|
return $this->curlHandlers[$endpoint];
|
||||||
@@ -79,9 +79,9 @@ class LogglyHandler extends AbstractProcessingHandler
|
|||||||
*
|
*
|
||||||
* @param string $endpoint
|
* @param string $endpoint
|
||||||
*
|
*
|
||||||
* @return resource
|
* @return resource|\CurlHandle
|
||||||
*/
|
*/
|
||||||
private function loadCurlHandler(string $endpoint)
|
private function loadCurlHandle(string $endpoint)
|
||||||
{
|
{
|
||||||
$url = sprintf("https://%s/%s/%s/", static::HOST, $endpoint, $this->token);
|
$url = sprintf("https://%s/%s/%s/", static::HOST, $endpoint, $this->token);
|
||||||
|
|
||||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
|||||||
|
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Swift;
|
use Swift;
|
||||||
|
use Swift_Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MandrillHandler uses cURL to send the emails to the Mandrill API
|
* MandrillHandler uses cURL to send the emails to the Mandrill API
|
||||||
@@ -21,14 +22,16 @@ use Swift;
|
|||||||
*/
|
*/
|
||||||
class MandrillHandler extends MailHandler
|
class MandrillHandler extends MailHandler
|
||||||
{
|
{
|
||||||
|
/** @var Swift_Message */
|
||||||
protected $message;
|
protected $message;
|
||||||
|
/** @var string */
|
||||||
protected $apiKey;
|
protected $apiKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-param Swift_Message|callable(string, array): Swift_Message $message
|
* @psalm-param Swift_Message|callable(): Swift_Message $message
|
||||||
*
|
*
|
||||||
* @param string $apiKey A valid Mandrill API key
|
* @param string $apiKey A valid Mandrill API key
|
||||||
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
|
* @param callable|Swift_Message $message An example message for real messages, only the body will be replaced
|
||||||
* @param string|int $level The minimum logging level at which this handler will be triggered
|
* @param string|int $level The minimum logging level at which this handler will be triggered
|
||||||
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
@@ -36,10 +39,10 @@ class MandrillHandler extends MailHandler
|
|||||||
{
|
{
|
||||||
parent::__construct($level, $bubble);
|
parent::__construct($level, $bubble);
|
||||||
|
|
||||||
if (!$message instanceof \Swift_Message && is_callable($message)) {
|
if (!$message instanceof Swift_Message && is_callable($message)) {
|
||||||
$message = $message();
|
$message = $message();
|
||||||
}
|
}
|
||||||
if (!$message instanceof \Swift_Message) {
|
if (!$message instanceof Swift_Message) {
|
||||||
throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
|
throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
|
||||||
}
|
}
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
@@ -58,9 +61,11 @@ class MandrillHandler extends MailHandler
|
|||||||
|
|
||||||
$message = clone $this->message;
|
$message = clone $this->message;
|
||||||
$message->setBody($content, $mime);
|
$message->setBody($content, $mime);
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
||||||
$message->setDate(new \DateTimeImmutable());
|
$message->setDate(new \DateTimeImmutable());
|
||||||
} else {
|
} else {
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$message->setDate(time());
|
$message->setDate(time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -131,16 +131,24 @@ class OverflowHandler extends AbstractHandler implements FormattableHandlerInter
|
|||||||
*/
|
*/
|
||||||
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
||||||
{
|
{
|
||||||
|
if ($this->handler instanceof FormattableHandlerInterface) {
|
||||||
$this->handler->setFormatter($formatter);
|
$this->handler->setFormatter($formatter);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getFormatter(): FormatterInterface
|
public function getFormatter(): FormatterInterface
|
||||||
{
|
{
|
||||||
|
if ($this->handler instanceof FormattableHandlerInterface) {
|
||||||
return $this->handler->getFormatter();
|
return $this->handler->getFormatter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,9 +93,6 @@ class PHPConsoleHandler extends AbstractProcessingHandler
|
|||||||
return array_replace($this->options, $options);
|
return array_replace($this->options, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @suppress PhanTypeMismatchArgument
|
|
||||||
*/
|
|
||||||
private function initConnector(?Connector $connector = null): Connector
|
private function initConnector(?Connector $connector = null): Connector
|
||||||
{
|
{
|
||||||
if (!$connector) {
|
if (!$connector) {
|
||||||
|
@@ -27,7 +27,6 @@ trait ProcessableHandlerTrait
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @suppress PhanTypeMismatchReturn
|
|
||||||
*/
|
*/
|
||||||
public function pushProcessor(callable $callback): HandlerInterface
|
public function pushProcessor(callable $callback): HandlerInterface
|
||||||
{
|
{
|
||||||
|
@@ -100,16 +100,26 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
|
|||||||
*/
|
*/
|
||||||
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
public function setFormatter(FormatterInterface $formatter): HandlerInterface
|
||||||
{
|
{
|
||||||
$this->getHandler()->setFormatter($formatter);
|
$handler = $this->getHandler();
|
||||||
|
if ($handler instanceof FormattableHandlerInterface) {
|
||||||
|
$handler->setFormatter($formatter);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getFormatter(): FormatterInterface
|
public function getFormatter(): FormatterInterface
|
||||||
{
|
{
|
||||||
return $this->getHandler()->getFormatter();
|
$handler = $this->getHandler();
|
||||||
|
if ($handler instanceof FormattableHandlerInterface) {
|
||||||
|
return $handler->getFormatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@ class SlackRecord
|
|||||||
private $excludeFields;
|
private $excludeFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FormatterInterface
|
* @var ?FormatterInterface
|
||||||
*/
|
*/
|
||||||
private $formatter;
|
private $formatter;
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ class SlackRecord
|
|||||||
*
|
*
|
||||||
* @param ?string $channel
|
* @param ?string $channel
|
||||||
*
|
*
|
||||||
* @return SlackHandler
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function setChannel(?string $channel = null): self
|
public function setChannel(?string $channel = null): self
|
||||||
{
|
{
|
||||||
@@ -240,7 +240,7 @@ class SlackRecord
|
|||||||
*
|
*
|
||||||
* @param ?string $username
|
* @param ?string $username
|
||||||
*
|
*
|
||||||
* @return SlackHandler
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function setUsername(?string $username = null): self
|
public function setUsername(?string $username = null): self
|
||||||
{
|
{
|
||||||
|
@@ -93,9 +93,11 @@ class SwiftMailerHandler extends MailHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
$message->setBody($content, $mime);
|
$message->setBody($content, $mime);
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
|
||||||
$message->setDate(new \DateTimeImmutable());
|
$message->setDate(new \DateTimeImmutable());
|
||||||
} else {
|
} else {
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$message->setDate(time());
|
$message->setDate(time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -94,7 +94,7 @@ class SyslogUdpHandler extends AbstractSyslogHandler
|
|||||||
$hostname = '-';
|
$hostname = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->rfc === self::RFC3164) {
|
if ($this->rfc === self::RFC3164 && ($datetime instanceof \DateTimeImmutable || $datetime instanceof \DateTime)) {
|
||||||
$datetime->setTimezone(new \DateTimeZone('UTC'));
|
$datetime->setTimezone(new \DateTimeZone('UTC'));
|
||||||
}
|
}
|
||||||
$date = $datetime->format($this->dateFormats[$this->rfc]);
|
$date = $datetime->format($this->dateFormats[$this->rfc]);
|
||||||
|
@@ -73,7 +73,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler
|
|||||||
* Write to Zend Monitor Events
|
* Write to Zend Monitor Events
|
||||||
* @param string $type Text displayed in "Class Name (custom)" field
|
* @param string $type Text displayed in "Class Name (custom)" field
|
||||||
* @param string $message Text displayed in "Error String"
|
* @param string $message Text displayed in "Error String"
|
||||||
* @param mixed $formatted Displayed in Custom Variables tab
|
* @param array $formatted Displayed in Custom Variables tab
|
||||||
* @param int $severity Set the event severity level (-1,0,1)
|
* @param int $severity Set the event severity level (-1,0,1)
|
||||||
*/
|
*/
|
||||||
protected function writeZendMonitorCustomEvent(string $type, string $message, array $formatted, int $severity): void
|
protected function writeZendMonitorCustomEvent(string $type, string $message, array $formatted, int $severity): void
|
||||||
|
@@ -41,9 +41,6 @@ class SignalHandler
|
|||||||
|
|
||||||
if ($callPrevious) {
|
if ($callPrevious) {
|
||||||
$handler = pcntl_signal_get_handler($signo);
|
$handler = pcntl_signal_get_handler($signo);
|
||||||
if ($handler === false) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
$this->previousSignalHandler[$signo] = $handler;
|
$this->previousSignalHandler[$signo] = $handler;
|
||||||
} else {
|
} else {
|
||||||
unset($this->previousSignalHandler[$signo]);
|
unset($this->previousSignalHandler[$signo]);
|
||||||
|
@@ -49,9 +49,6 @@ class TestCase extends \PHPUnit\Framework\TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @suppress PhanTypeMismatchReturn
|
|
||||||
*/
|
|
||||||
protected function getIdentityFormatter(): FormatterInterface
|
protected function getIdentityFormatter(): FormatterInterface
|
||||||
{
|
{
|
||||||
$formatter = $this->createMock(FormatterInterface::class);
|
$formatter = $this->createMock(FormatterInterface::class);
|
||||||
|
Reference in New Issue
Block a user