diff --git a/src/DependencyInjection/Compiler/AddProcessorsPass.php b/src/DependencyInjection/Compiler/AddProcessorsPass.php index e325ea16..b804f6db 100644 --- a/src/DependencyInjection/Compiler/AddProcessorsPass.php +++ b/src/DependencyInjection/Compiler/AddProcessorsPass.php @@ -38,7 +38,7 @@ public function process(ContainerBuilder $container) foreach ($tags as $tag) { if (!empty($tag['channel']) && !empty($tag['handler'])) { - throw new \InvalidArgumentException(\sprintf('you cannot specify both the "handler" and "channel" attributes for the "monolog.processor" tag on service "%s"', $id)); + throw new \InvalidArgumentException(\sprintf('you cannot specify both the "handler" and "channel" attributes for the "monolog.processor" tag on service "%s".', $id)); } if (!empty($tag['handler'])) { @@ -49,7 +49,7 @@ public function process(ContainerBuilder $container) } $class = $container->getParameterBag()->resolveValue($parentDef->getClass()); if (!method_exists($class, 'pushProcessor')) { - throw new \InvalidArgumentException(\sprintf('The "%s" handler does not accept processors', $tag['handler'])); + throw new \InvalidArgumentException(\sprintf('The "%s" handler does not accept processors.', $tag['handler'])); } } elseif (!empty($tag['channel'])) { if ('app' === $tag['channel']) { diff --git a/src/DependencyInjection/Compiler/LoggerChannelPass.php b/src/DependencyInjection/Compiler/LoggerChannelPass.php index b4c513c0..434f33e1 100644 --- a/src/DependencyInjection/Compiler/LoggerChannelPass.php +++ b/src/DependencyInjection/Compiler/LoggerChannelPass.php @@ -97,8 +97,7 @@ public function process(ContainerBuilder $container) try { $logger = $container->getDefinition('app' === $channel ? 'monolog.logger' : 'monolog.logger.'.$channel); } catch (InvalidArgumentException $e) { - $msg = 'Monolog configuration error: The logging channel "'.$channel.'" assigned to the "'.substr($handler, 16).'" handler does not exist.'; - throw new \InvalidArgumentException($msg, 0, $e); + throw new \InvalidArgumentException(\sprintf('Monolog configuration error: The logging channel "%s" assigned to the "%s" handler does not exist.', $channel, substr($handler, 16)), 0, $e); } $logger->addMethodCall('pushHandler', [new Reference($handler)]); } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 1db66fa7..ae176445 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -777,7 +777,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->then(function ($v) { $invalidTags = preg_grep('/^[a-z0-9][a-z0-9\.\-_]*$/i', $v['tags'], \PREG_GREP_INVERT); if (!empty($invalidTags)) { - throw new InvalidConfigurationException(\sprintf('The following Loggly tags are invalid: %s.', implode(', ', $invalidTags))); + throw new InvalidConfigurationException(\sprintf('The following Loggly tags are invalid: "%s".', implode('", "', $invalidTags))); } return $v; @@ -1124,7 +1124,7 @@ private function addChannelsSection(ArrayNodeDefinition $handlerNode) $isExclusive = true; } else { if (true === $isExclusive) { - throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list'); + throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list.'); } $elements[] = $element; $isExclusive = false; diff --git a/src/DependencyInjection/MonologExtension.php b/src/DependencyInjection/MonologExtension.php index 77ce0916..73c50ffe 100644 --- a/src/DependencyInjection/MonologExtension.php +++ b/src/DependencyInjection/MonologExtension.php @@ -233,7 +233,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler $publisher->setPublic(false); } else { - throw new \RuntimeException('The gelf handler requires the graylog2/gelf-php package to be installed'); + throw new \RuntimeException('The gelf handler requires the graylog2/gelf-php package to be installed.'); } $definition->setArguments([ @@ -330,7 +330,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler case 'telegram': if (!class_exists('Monolog\Handler\TelegramBotHandler')) { - throw new \RuntimeException('The TelegramBotHandler is not available. Please update "monolog/monolog" to 2.2.0'); + throw new \RuntimeException('The TelegramBotHandler is not available. Please update "monolog/monolog" to 2.2.0.'); } $definition->setArguments([ @@ -916,7 +916,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler $nullWarning = ', if you meant to define a null handler in a yaml config, make sure you quote "null" so it does not get converted to a php null'; } - throw new \InvalidArgumentException(\sprintf('Invalid handler type "%s" given for handler "%s"'.$nullWarning, $handler['type'], $name)); + throw new \InvalidArgumentException(\sprintf('Invalid handler type "%s" given for handler "%s".'.$nullWarning, $handler['type'], $name)); } if (!empty($handler['nested']) && true === $handler['nested']) { diff --git a/tests/DependencyInjection/MonologExtensionTest.php b/tests/DependencyInjection/MonologExtensionTest.php index c003440f..3efa10e6 100644 --- a/tests/DependencyInjection/MonologExtensionTest.php +++ b/tests/DependencyInjection/MonologExtensionTest.php @@ -527,7 +527,7 @@ public function testLogglyHandler() ]]]]); $this->fail(); } catch (InvalidConfigurationException $e) { - $this->assertStringContainsString('-us, apache$', $e->getMessage()); + $this->assertSame('The following Loggly tags are invalid: "-us", "apache$".', $e->getMessage()); } $container = $this->getContainer([['handlers' => ['loggly' => [