Skip to content

Commit

Permalink
Check whether graylog2/gelf-php is installed in GelfMessageFormatter …
Browse files Browse the repository at this point in the history
…constructor (#1624)
  • Loading branch information
b1rdex committed Mar 7, 2022
1 parent 832660e commit baf2d9d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Monolog/Formatter/GelfMessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit baf2d9d

Please sign in to comment.