Ver Fonte

Check whether graylog2/gelf-php is installed in GelfMessageFormatter constructor (#1624)

Anatoly Pashin há 3 anos atrás
pai
commit
baf2d9d4a7
1 ficheiros alterados com 4 adições e 0 exclusões
  1. 4 0
      src/Monolog/Formatter/GelfMessageFormatter.php

+ 4 - 0
src/Monolog/Formatter/GelfMessageFormatter.php

@@ -67,6 +67,10 @@ class GelfMessageFormatter extends NormalizerFormatter
 
     public function __construct(?string $systemName = null, ?string $extraPrefix = null, string $contextPrefix = 'ctxt_', ?int $maxLength = null)
     {
+        if (!class_exists(Message::class)) {
+            throw new \RuntimeException('Composer package graylog2/gelf-php is required to use Monolog\'s GelfMessageFormatter');
+        }
+
         parent::__construct('U.u');
 
         $this->systemName = (is_null($systemName) || $systemName === '') ? (string) gethostname() : $systemName;