1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-30 09:50:26 +02:00

Remove pointless json_encode availability checks (#1919)

Co-authored-by: Jens Hatlak <jens.hatlak@check24.de>
This commit is contained in:
InvisibleSmiley
2024-10-25 21:45:46 +02:00
committed by GitHub
parent 2497a896b1
commit 63fdb125ab
10 changed files with 2 additions and 32 deletions

View File

@@ -34,8 +34,6 @@ class ElasticaFormatter extends NormalizerFormatter
/**
* @param string $index Elastic Search index name
* @param ?string $type Elastic Search document type, deprecated as of Elastica 7
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $index, ?string $type)
{

View File

@@ -34,8 +34,6 @@ class ElasticsearchFormatter extends NormalizerFormatter
/**
* @param string $index Elasticsearch index name
* @param string $type Elasticsearch record type
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $index, string $type)
{

View File

@@ -42,15 +42,8 @@ class FluentdFormatter implements FormatterInterface
*/
protected bool $levelTag = false;
/**
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(bool $levelTag = false)
{
if (!\function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
}
$this->levelTag = $levelTag;
}

View File

@@ -42,8 +42,7 @@ class HtmlFormatter extends NormalizerFormatter
}
/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
*/
public function __construct(?string $dateFormat = null)
{

View File

@@ -38,8 +38,6 @@ class JsonFormatter extends NormalizerFormatter
/**
* @param self::BATCH_MODE_* $batchMode
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
{

View File

@@ -40,8 +40,6 @@ class LineFormatter extends NormalizerFormatter
* @param string|null $format The format of the message
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
{

View File

@@ -48,8 +48,6 @@ class LogstashFormatter extends NormalizerFormatter
* @param string|null $systemName The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
* @param string $extraKey The key for extra keys inside logstash "fields", defaults to extra
* @param string $contextKey The key for context keys inside logstash "fields", defaults to context
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context')
{

View File

@@ -34,15 +34,11 @@ class NormalizerFormatter implements FormatterInterface
protected string $basePath = '';
/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
*/
public function __construct(?string $dateFormat = null)
{
$this->dateFormat = null === $dateFormat ? static::SIMPLE_DATE : $dateFormat;
if (!\function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter');
}
}
/**

View File

@@ -25,8 +25,6 @@ class WildfireFormatter extends NormalizerFormatter
{
/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $dateFormat = null)
{

View File

@@ -62,15 +62,9 @@ class ChromePHPHandler extends AbstractProcessingHandler
protected static bool $sendHeaders = true;
/**
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true)
{
parent::__construct($level, $bubble);
if (!\function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s ChromePHPHandler');
}
}
/**