diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 161f12ea..c38fcedc 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -30,7 +30,7 @@ jobs:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
- monolog: [ '1.*', '2.*' ]
+ monolog: [ '2.*' ]
include:
- php: '7.4'
deps: lowest
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 71857560..717f752c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
## Unreleased
+* Drop support for Monolog 1
+
## 3.10.0 (2023-11-06)
* Add configuration support for SamplingHandler
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 255eba47..3db7cf6c 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -223,17 +223,15 @@
* - [timeout]: float
* - [connection_timeout]: float
*
- * - raven / sentry:
+ * - sentry:
* - dsn: connection string
* - client_id: Raven client custom service id (optional)
+ * - hub_id: Sentry hub custom service id (optional)
* - [release]: release number of the application that will be attached to logs, defaults to null
* - [level]: level name or int value, defaults to DEBUG
* - [bubble]: bool, defaults to true
* - [auto_log_stacks]: bool, defaults to false
* - [environment]: string, default to null (no env specified)
- *
- * - sentry:
- * - hub_id: Sentry hub custom service id (optional)
* - [fill_extra_context]: bool, defaults to false
*
* - newrelic:
@@ -241,20 +239,6 @@
* - [bubble]: bool, defaults to true
* - [app_name]: new relic app name, default null
*
- * - hipchat:
- * - token: hipchat api token
- * - room: room id or name
- * - [notify]: defaults to false
- * - [nickname]: defaults to Monolog
- * - [level]: level name or int value, defaults to DEBUG
- * - [bubble]: bool, defaults to true
- * - [use_ssl]: bool, defaults to true
- * - [message_format]: text or html, defaults to text
- * - [host]: defaults to "api.hipchat.com"
- * - [api_version]: defaults to "v1"
- * - [timeout]: float
- * - [connection_timeout]: float
- *
* - slack:
* - token: slack api token
* - channel: channel name (with starting #)
@@ -279,13 +263,6 @@
* - [level]: level name or int value, defaults to DEBUG
* - [bubble]: bool, defaults to true
*
- * - slackbot:
- * - team: slack team slug
- * - token: slackbot token
- * - channel: channel name (with starting #)
- * - [level]: level name or int value, defaults to DEBUG
- * - [bubble]: bool, defaults to true
- *
* - cube:
* - url: http/udp url to the cube server
* - [level]: level name or int value, defaults to DEBUG
@@ -538,23 +515,17 @@ public function getConfigTreeBuilder(): TreeBuilder
->scalarNode('url')->end() // cube
->scalarNode('exchange')->end() // amqp
->scalarNode('exchange_name')->defaultValue('log')->end() // amqp
- ->scalarNode('room')->end() // hipchat
- ->scalarNode('message_format')->defaultValue('text')->end() // hipchat
- ->scalarNode('api_version')->defaultNull()->end() // hipchat
- ->scalarNode('channel')->defaultNull()->end() // slack & slackwebhook & slackbot & telegram
+ ->scalarNode('channel')->defaultNull()->end() // slack & slackwebhook & telegram
->scalarNode('bot_name')->defaultValue('Monolog')->end() // slack & slackwebhook
->scalarNode('use_attachment')->defaultTrue()->end() // slack & slackwebhook
->scalarNode('use_short_attachment')->defaultFalse()->end() // slack & slackwebhook
->scalarNode('include_extra')->defaultFalse()->end() // slack & slackwebhook
->scalarNode('icon_emoji')->defaultNull()->end() // slack & slackwebhook
->scalarNode('webhook_url')->end() // slackwebhook
- ->scalarNode('team')->end() // slackbot
- ->scalarNode('notify')->defaultFalse()->end() // hipchat
- ->scalarNode('nickname')->defaultValue('Monolog')->end() // hipchat
- ->scalarNode('token')->end() // pushover & hipchat & loggly & logentries & flowdock & rollbar & slack & slackbot & insightops & telegram
+ ->scalarNode('token')->end() // pushover & loggly & logentries & flowdock & rollbar & slack & insightops & telegram
->scalarNode('region')->end() // insightops
->scalarNode('source')->end() // flowdock
- ->booleanNode('use_ssl')->defaultTrue()->end() // logentries & hipchat & insightops
+ ->booleanNode('use_ssl')->defaultTrue()->end() // logentries & insightops
->variableNode('user') // pushover
->validate()
->ifTrue(function ($v) {
@@ -564,7 +535,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->end()
->scalarNode('title')->defaultNull()->end() // pushover
- ->scalarNode('host')->defaultNull()->end() // syslogudp & hipchat
+ ->scalarNode('host')->defaultNull()->end() // syslogudp
->scalarNode('port')->defaultValue(514)->end() // syslogudp
->arrayNode('config')
->canBeUnset()
@@ -576,18 +547,17 @@ public function getConfigTreeBuilder(): TreeBuilder
->prototype('scalar')->end()
->end()
->scalarNode('connection_string')->end() // socket_handler
- ->scalarNode('timeout')->end() // socket_handler, logentries, pushover, hipchat & slack
+ ->scalarNode('timeout')->end() // socket_handler, logentries, pushover & slack
->scalarNode('time')->defaultValue(60)->end() // deduplication
->scalarNode('deduplication_level')->defaultValue(Logger::ERROR)->end() // deduplication
->scalarNode('store')->defaultNull()->end() // deduplication
- ->scalarNode('connection_timeout')->end() // socket_handler, logentries, pushover, hipchat & slack
+ ->scalarNode('connection_timeout')->end() // socket_handler, logentries, pushover & slack
->booleanNode('persistent')->end() // socket_handler
- ->scalarNode('dsn')->end() // raven_handler, sentry_handler
+ ->scalarNode('dsn')->end() // sentry_handler
->scalarNode('hub_id')->defaultNull()->end() // sentry_handler
- ->scalarNode('client_id')->defaultNull()->end() // raven_handler, sentry_handler
- ->scalarNode('auto_log_stacks')->defaultFalse()->end() // raven_handler
- ->scalarNode('release')->defaultNull()->end() // raven_handler, sentry_handler
- ->scalarNode('environment')->defaultNull()->end() // raven_handler, sentry_handler
+ ->scalarNode('client_id')->defaultNull()->end() // sentry_handler
+ ->scalarNode('release')->defaultNull()->end() // sentry_handler
+ ->scalarNode('environment')->defaultNull()->end() // sentry_handler
->scalarNode('message_type')->defaultValue(0)->end() // error_log
->scalarNode('parse_mode')->defaultNull()->end() // telegram
->booleanNode('disable_webpage_preview')->defaultNull()->end() // telegram
@@ -713,10 +683,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->ifTrue(function ($v) { return 'pushover' === $v['type'] && (empty($v['token']) || empty($v['user'])); })
->thenInvalid('The token and user have to be specified to use a PushoverHandler')
->end()
- ->validate()
- ->ifTrue(function ($v) { return 'raven' === $v['type'] && !\array_key_exists('dsn', $v) && null === $v['client_id']; })
- ->thenInvalid('The DSN has to be specified to use a RavenHandler')
- ->end()
->validate()
->ifTrue(function ($v) { return 'sentry' === $v['type'] && !\array_key_exists('dsn', $v) && null === $v['hub_id'] && null === $v['client_id']; })
->thenInvalid('The DSN has to be specified to use Sentry\'s handler')
@@ -725,18 +691,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->ifTrue(function ($v) { return 'sentry' === $v['type'] && null !== $v['hub_id'] && null !== $v['client_id']; })
->thenInvalid('You can not use both a hub_id and a client_id in a Sentry handler')
->end()
- ->validate()
- ->ifTrue(function ($v) { return 'hipchat' === $v['type'] && (empty($v['token']) || empty($v['room'])); })
- ->thenInvalid('The token and room have to be specified to use a HipChatHandler')
- ->end()
- ->validate()
- ->ifTrue(function ($v) { return 'hipchat' === $v['type'] && !\in_array($v['message_format'], ['text', 'html']); })
- ->thenInvalid('The message_format has to be "text" or "html" in a HipChatHandler')
- ->end()
- ->validate()
- ->ifTrue(function ($v) { return 'hipchat' === $v['type'] && null !== $v['api_version'] && !\in_array($v['api_version'], ['v1', 'v2'], true); })
- ->thenInvalid('The api_version has to be "v1" or "v2" in a HipChatHandler')
- ->end()
->validate()
->ifTrue(function ($v) { return 'slack' === $v['type'] && (empty($v['token']) || empty($v['channel'])); })
->thenInvalid('The token and channel have to be specified to use a SlackHandler')
@@ -745,10 +699,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->ifTrue(function ($v) { return 'slackwebhook' === $v['type'] && (empty($v['webhook_url'])); })
->thenInvalid('The webhook_url have to be specified to use a SlackWebhookHandler')
->end()
- ->validate()
- ->ifTrue(function ($v) { return 'slackbot' === $v['type'] && (empty($v['team']) || empty($v['token']) || empty($v['channel'])); })
- ->thenInvalid('The team, token and channel have to be specified to use a SlackbotHandler')
- ->end()
->validate()
->ifTrue(function ($v) { return 'cube' === $v['type'] && empty($v['url']); })
->thenInvalid('The url has to be specified to use a CubeHandler')
diff --git a/DependencyInjection/MonologExtension.php b/DependencyInjection/MonologExtension.php
index 1d47a984..a30bdf91 100644
--- a/DependencyInjection/MonologExtension.php
+++ b/DependencyInjection/MonologExtension.php
@@ -229,14 +229,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
$publisher = new Definition('Gelf\Publisher', []);
$publisher->addMethodCall('addTransport', [$transport]);
- $publisher->setPublic(false);
- } elseif (class_exists('Gelf\MessagePublisher')) {
- $publisher = new Definition('Gelf\MessagePublisher', [
- $handler['publisher']['hostname'],
- $handler['publisher']['port'],
- $handler['publisher']['chunk_size'],
- ]);
-
$publisher->setPublic(false);
} else {
throw new \RuntimeException('The gelf handler requires the graylog2/gelf-php package to be installed');
@@ -632,27 +624,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
}
break;
- case 'hipchat':
- $definition->setArguments([
- $handler['token'],
- $handler['room'],
- $handler['nickname'],
- $handler['notify'],
- $handler['level'],
- $handler['bubble'],
- $handler['use_ssl'],
- $handler['message_format'],
- !empty($handler['host']) ? $handler['host'] : 'api.hipchat.com',
- !empty($handler['api_version']) ? $handler['api_version'] : 'v1',
- ]);
- if (isset($handler['timeout'])) {
- $definition->addMethodCall('setTimeout', [$handler['timeout']]);
- }
- if (isset($handler['connection_timeout'])) {
- $definition->addMethodCall('setConnectionTimeout', [$handler['connection_timeout']]);
- }
- break;
-
case 'slack':
$definition->setArguments([
$handler['token'],
@@ -687,16 +658,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
]);
break;
- case 'slackbot':
- $definition->setArguments([
- $handler['team'],
- $handler['token'],
- urlencode($handler['channel']),
- $handler['level'],
- $handler['bubble'],
- ]);
- break;
-
case 'cube':
$definition->setArguments([
$handler['url'],
@@ -773,31 +734,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
]);
break;
- case 'raven':
- if (null !== $handler['client_id']) {
- $clientId = $handler['client_id'];
- } else {
- $client = new Definition('Raven_Client', [
- $handler['dsn'],
- [
- 'auto_log_stacks' => $handler['auto_log_stacks'],
- 'environment' => $handler['environment'],
- ],
- ]);
- $client->setPublic(false);
- $clientId = 'monolog.raven.client.'.sha1($handler['dsn']);
- $container->setDefinition($clientId, $client);
- }
- $definition->setArguments([
- new Reference($clientId),
- $handler['level'],
- $handler['bubble'],
- ]);
- if (!empty($handler['release'])) {
- $definition->addMethodCall('setRelease', [$handler['release']]);
- }
- break;
-
case 'loggly':
$definition->setArguments([
$handler['token'],
@@ -975,13 +911,10 @@ private function getHandlerClassByType($handlerType)
'symfony_mailer' => 'Symfony\Bridge\Monolog\Handler\MailerHandler',
'socket' => 'Monolog\Handler\SocketHandler',
'pushover' => 'Monolog\Handler\PushoverHandler',
- 'raven' => 'Monolog\Handler\RavenHandler',
'sentry' => 'Sentry\Monolog\Handler',
'newrelic' => 'Monolog\Handler\NewRelicHandler',
- 'hipchat' => 'Monolog\Handler\HipChatHandler',
'slack' => 'Monolog\Handler\SlackHandler',
'slackwebhook' => 'Monolog\Handler\SlackWebhookHandler',
- 'slackbot' => 'Monolog\Handler\SlackbotHandler',
'cube' => 'Monolog\Handler\CubeHandler',
'amqp' => 'Monolog\Handler\AmqpHandler',
'error_log' => 'Monolog\Handler\ErrorLogHandler',
@@ -991,16 +924,12 @@ private function getHandlerClassByType($handlerType)
'fingers_crossed' => 'Monolog\Handler\FingersCrossedHandler',
'filter' => 'Monolog\Handler\FilterHandler',
'mongo' => 'Monolog\Handler\MongoDBHandler',
- 'elasticsearch' => 'Monolog\Handler\ElasticSearchHandler',
'telegram' => 'Monolog\Handler\TelegramBotHandler',
'server_log' => 'Symfony\Bridge\Monolog\Handler\ServerLogHandler',
'redis' => 'Monolog\Handler\RedisHandler',
'predis' => 'Monolog\Handler\RedisHandler',
'insightops' => 'Monolog\Handler\InsightOpsHandler',
'sampling' => 'Monolog\Handler\SamplingHandler',
- ];
-
- $v2HandlerTypesAdded = [
'elastica' => 'Monolog\Handler\ElasticaHandler',
'elasticsearch' => 'Monolog\Handler\ElasticaHandler',
'elastic_search' => 'Monolog\Handler\ElasticsearchHandler',
@@ -1008,23 +937,10 @@ private function getHandlerClassByType($handlerType)
'noop' => 'Monolog\Handler\NoopHandler',
];
- $v2HandlerTypesRemoved = [
- 'hipchat',
- 'raven',
- 'slackbot',
- ];
-
$v3HandlerTypesRemoved = [
'swift_mailer',
];
- if (Logger::API >= 2) {
- $typeToClassMapping = array_merge($typeToClassMapping, $v2HandlerTypesAdded);
- foreach ($v2HandlerTypesRemoved as $v2HandlerTypeRemoved) {
- unset($typeToClassMapping[$v2HandlerTypeRemoved]);
- }
- }
-
if (Logger::API >= 3) {
foreach ($v3HandlerTypesRemoved as $v3HandlerTypeRemoved) {
unset($typeToClassMapping[$v3HandlerTypeRemoved]);
@@ -1032,14 +948,6 @@ private function getHandlerClassByType($handlerType)
}
if (!isset($typeToClassMapping[$handlerType])) {
- if (Logger::API === 1 && \array_key_exists($handlerType, $v2HandlerTypesAdded)) {
- throw new \InvalidArgumentException(\sprintf('"%s" was added in Monolog v2, please upgrade if you wish to use it.', $handlerType));
- }
-
- if (Logger::API >= 2 && \array_key_exists($handlerType, $v2HandlerTypesRemoved)) {
- throw new \InvalidArgumentException(\sprintf('"%s" was removed in Monolog v2.', $handlerType));
- }
-
if (Logger::API >= 3 && \array_key_exists($handlerType, $v3HandlerTypesRemoved)) {
throw new \InvalidArgumentException(\sprintf('"%s" was removed in Monolog v3.', $handlerType));
}
diff --git a/Resources/config/schema/monolog-1.0.xsd b/Resources/config/schema/monolog-1.0.xsd
index b00e969e..37683915 100644
--- a/Resources/config/schema/monolog-1.0.xsd
+++ b/Resources/config/schema/monolog-1.0.xsd
@@ -57,9 +57,6 @@
-
-
-
@@ -86,11 +83,9 @@
-
-
diff --git a/Tests/DependencyInjection/Compiler/AddProcessorsPassTest.php b/Tests/DependencyInjection/Compiler/AddProcessorsPassTest.php
index c11c2a33..0ac5d775 100644
--- a/Tests/DependencyInjection/Compiler/AddProcessorsPassTest.php
+++ b/Tests/DependencyInjection/Compiler/AddProcessorsPassTest.php
@@ -12,7 +12,6 @@
namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler;
use Monolog\Handler\NullHandler;
-use Monolog\Logger;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddProcessorsPass;
@@ -53,16 +52,9 @@ public function testFailureOnHandlerWithoutPushProcessor()
$container->getCompilerPassConfig()->setRemovingPasses([]);
$container->addCompilerPass(new AddProcessorsPass());
- if (Logger::API < 2) {
- $container->compile();
- $service = $container->getDefinition('monolog.handler.test3');
- $calls = $service->getMethodCalls();
- $this->assertCount(1, $calls);
- } else {
- $this->expectException(\InvalidArgumentException::class);
- $this->expectExceptionMessage('The "test3" handler does not accept processors');
- $container->compile();
- }
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('The "test3" handler does not accept processors');
+ $container->compile();
}
protected function getContainer()
diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php
index d581a049..98f1cc71 100644
--- a/Tests/DependencyInjection/ConfigurationTest.php
+++ b/Tests/DependencyInjection/ConfigurationTest.php
@@ -194,7 +194,7 @@ public function testMergingInvalidChannels()
public function testWithSwiftMailerHandler()
{
if (Logger::API >= 3) {
- $this->markTestSkipped('This test requires Monolog v1 or v2');
+ $this->markTestSkipped('This test requires Monolog v2');
}
$configs = [
diff --git a/Tests/DependencyInjection/FixtureMonologExtensionTestCase.php b/Tests/DependencyInjection/FixtureMonologExtensionTestCase.php
index fb6dbf96..c47b3d09 100644
--- a/Tests/DependencyInjection/FixtureMonologExtensionTestCase.php
+++ b/Tests/DependencyInjection/FixtureMonologExtensionTestCase.php
@@ -12,7 +12,6 @@
namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
-use Monolog\Processor\PsrLogMessageProcessor;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -149,7 +148,7 @@ public function testHandlersWithChannels()
public function testSingleEmailRecipient()
{
if (\Monolog\Logger::API >= 3) {
- $this->markTestSkipped('This test requires Monolog v1 or v2');
+ $this->markTestSkipped('This test requires Monolog v2');
}
$container = $this->getContainer('single_email_recipient');
@@ -177,7 +176,7 @@ public function testServerLog()
public function testMultipleEmailRecipients()
{
if (\Monolog\Logger::API >= 3) {
- $this->markTestSkipped('This test requires Monolog v1 or v2');
+ $this->markTestSkipped('This test requires Monolog v2');
}
$container = $this->getContainer('multiple_email_recipients');
@@ -216,9 +215,6 @@ public function testPsr3MessageProcessingEnabled()
public function testPsr3MessageProcessingDisabledOnNullHandler()
{
- if (\Monolog\Logger::API < 2) {
- $this->markTestSkipped('This test requires Monolog v2 or above');
- }
$container = $this->getContainer('process_psr_3_messages_null');
$logger = $container->getDefinition('monolog.handler.custom');
@@ -230,9 +226,6 @@ public function testPsr3MessageProcessingDisabledOnNullHandler()
public function testHandlersV2()
{
- if (\Monolog\Logger::API < 2) {
- $this->markTestSkipped('This test requires Monolog v2 or above');
- }
$this->getContainer('handlers');
$this->expectNotToPerformAssertions();
@@ -251,11 +244,6 @@ public function testPsr3MessageProcessingDisabled()
public function testPsrLogMessageProcessorHasConstructorArguments(): void
{
- $reflectionConstructor = (new \ReflectionClass(PsrLogMessageProcessor::class))->getConstructor();
- if (null === $reflectionConstructor || $reflectionConstructor->getNumberOfParameters() <= 0) {
- $this->markTestSkipped('Monolog >= 1.26 is needed.');
- }
-
$container = $this->getContainer('process_psr_3_messages_with_arguments');
$processors = [
@@ -276,28 +264,6 @@ public function testPsrLogMessageProcessorHasConstructorArguments(): void
}
}
- public function testPsrLogMessageProcessorDoesNotHaveConstructorArguments(): void
- {
- $reflectionConstructor = (new \ReflectionClass(PsrLogMessageProcessor::class))->getConstructor();
- if (null !== $reflectionConstructor && $reflectionConstructor->getNumberOfParameters() > 0) {
- $this->markTestSkipped('Monolog < 1.26 is needed.');
- }
-
- $container = $this->getContainer('process_psr_3_messages_without_arguments');
-
- $this->assertTrue($container->hasDefinition($processorId = 'monolog.processor.psr_log_message'));
- $processor = $container->getDefinition($processorId);
- $this->assertDICConstructorArguments($processor, []);
-
- $this->assertTrue($container->hasDefinition($handlerId = 'monolog.handler.without_arguments'));
- $handler = $container->getDefinition($handlerId);
- $this->assertDICDefinitionMethodCallAt(0, $handler, 'pushProcessor', [new Reference($processorId)]);
-
- $this->expectException(\RuntimeException::class);
- $this->expectExceptionMessage('Monolog 1.26 or higher is required for the "date_format" and "remove_used_context_fields" options to be used.');
- $this->getContainer('process_psr_3_messages_with_arguments');
- }
-
public function testNativeMailer()
{
$container = $this->getContainer('native_mailer');
diff --git a/Tests/DependencyInjection/Fixtures/xml/process_psr_3_messages_without_arguments.xml b/Tests/DependencyInjection/Fixtures/xml/process_psr_3_messages_without_arguments.xml
deleted file mode 100644
index 288eb750..00000000
--- a/Tests/DependencyInjection/Fixtures/xml/process_psr_3_messages_without_arguments.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/Tests/DependencyInjection/Fixtures/yml/process_psr_3_messages_without_arguments.yml b/Tests/DependencyInjection/Fixtures/yml/process_psr_3_messages_without_arguments.yml
deleted file mode 100644
index b04e190c..00000000
--- a/Tests/DependencyInjection/Fixtures/yml/process_psr_3_messages_without_arguments.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-monolog:
- handlers:
- without_arguments:
- type: stream
- process_psr_3_messages:
- enabled: true
diff --git a/Tests/DependencyInjection/MonologExtensionTest.php b/Tests/DependencyInjection/MonologExtensionTest.php
index eb02825f..0dee0ccc 100644
--- a/Tests/DependencyInjection/MonologExtensionTest.php
+++ b/Tests/DependencyInjection/MonologExtensionTest.php
@@ -15,7 +15,6 @@
use Monolog\Attribute\WithMonologChannel;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\RollbarHandler;
-use Monolog\Logger;
use Monolog\Processor\UidProcessor;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
@@ -287,88 +286,6 @@ public function testSocketHandler()
$this->assertDICDefinitionMethodCallAt(3, $handler, 'setPersistent', [true]);
}
- public function testRavenHandlerWhenConfigurationIsWrong()
- {
- if (Logger::API !== 1) {
- $this->markTestSkipped('Only valid on Monolog V1');
-
- return;
- }
-
- try {
- $this->getContainer([['handlers' => ['raven' => ['type' => 'raven']]]]);
- $this->fail();
- } catch (InvalidConfigurationException $e) {
- $this->assertStringContainsString('DSN', $e->getMessage());
- }
- }
-
- public function testRavenHandlerWhenADSNIsSpecified()
- {
- if (Logger::API !== 1) {
- $this->markTestSkipped('Only valid on Monolog V1');
-
- return;
- }
-
- $dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1';
-
- $container = $this->getContainer([['handlers' => ['raven' => [
- 'type' => 'raven', 'dsn' => $dsn,
- ]]]]);
- $this->assertTrue($container->hasDefinition('monolog.logger'));
- $this->assertTrue($container->hasDefinition('monolog.handler.raven'));
-
- $logger = $container->getDefinition('monolog.logger');
- $this->assertDICDefinitionMethodCallAt(0, $logger, 'useMicrosecondTimestamps', ['%monolog.use_microseconds%']);
- $this->assertDICDefinitionMethodCallAt(1, $logger, 'pushHandler', [new Reference('monolog.handler.raven')]);
-
- $this->assertTrue($container->hasDefinition('monolog.raven.client.'.sha1($dsn)));
-
- $handler = $container->getDefinition('monolog.handler.raven');
- $this->assertDICDefinitionClass($handler, 'Monolog\Handler\RavenHandler');
- }
-
- public function testRavenHandlerWhenADSNAndAClientAreSpecified()
- {
- if (Logger::API !== 1) {
- $this->markTestSkipped('Only valid on Monolog V1');
-
- return;
- }
-
- $container = $this->getContainer([['handlers' => ['raven' => [
- 'type' => 'raven', 'dsn' => 'foobar', 'client_id' => 'raven.client',
- ]]]], ['raven.client' => new Definition('Raven_Client')]);
-
- $logger = $container->getDefinition('monolog.logger');
- $this->assertDICDefinitionMethodCallAt(0, $logger, 'useMicrosecondTimestamps', ['%monolog.use_microseconds%']);
- $this->assertDICDefinitionMethodCallAt(1, $logger, 'pushHandler', [new Reference('monolog.handler.raven')]);
-
- $handler = $container->getDefinition('monolog.handler.raven');
- $this->assertDICConstructorArguments($handler, [new Reference('raven.client'), 'DEBUG', true]);
- }
-
- public function testRavenHandlerWhenAClientIsSpecified()
- {
- if (Logger::API !== 1) {
- $this->markTestSkipped('Only valid on Monolog V1');
-
- return;
- }
-
- $container = $this->getContainer([['handlers' => ['raven' => [
- 'type' => 'raven', 'client_id' => 'raven.client',
- ]]]], ['raven.client' => new Definition('Raven_Client')]);
-
- $logger = $container->getDefinition('monolog.logger');
- $this->assertDICDefinitionMethodCallAt(0, $logger, 'useMicrosecondTimestamps', ['%monolog.use_microseconds%']);
- $this->assertDICDefinitionMethodCallAt(1, $logger, 'pushHandler', [new Reference('monolog.handler.raven')]);
-
- $handler = $container->getDefinition('monolog.handler.raven');
- $this->assertDICConstructorArguments($handler, [new Reference('raven.client'), 'DEBUG', true]);
- }
-
public function testSentryHandlerWhenConfigurationIsWrong()
{
try {
@@ -611,47 +528,26 @@ public function testFingersCrossedHandlerWhenExcludedHttpCodesAreSpecified()
/**
* @dataProvider v2RemovedDataProvider
*/
- public function testV2Removed(array $handlerOptions)
+ public function testV2Removed(string $type)
{
- if (Logger::API === 1) {
- $this->markTestSkipped('Not valid for V1');
-
- return;
- }
-
$this->expectException(\InvalidArgumentException::class);
- $this->expectExceptionMessage(\sprintf('There is no handler class defined for handler "%s".', $handlerOptions['type']));
+ $this->expectExceptionMessage(\sprintf('There is no handler class defined for handler "%s".', $type));
$container = new ContainerBuilder();
$loader = new MonologExtension();
- $loader->load([['handlers' => ['main' => $handlerOptions]]], $container);
+ $loader->load([['handlers' => ['main' => ['type' => $type]]]], $container);
}
public static function v2RemovedDataProvider(): array
{
return [
- [['type' => 'hipchat', 'token' => 'abc123', 'room' => 'foo']],
- [['type' => 'raven', 'dsn' => 'foo']],
- [['type' => 'slackbot', 'team' => 'foo', 'token' => 'test1234', 'channel' => 'bar']],
+ ['hipchat'],
+ ['raven'],
+ ['slackbot'],
];
}
- public function testV2AddedOnV1()
- {
- if (Logger::API !== 1) {
- $this->markTestSkipped('Only valid on Monolog V1');
- }
-
- $this->expectException(\InvalidArgumentException::class);
- $this->expectExceptionMessage('"fallbackgroup" was added in Monolog v2, please upgrade if you wish to use it.');
-
- $container = new ContainerBuilder();
- $loader = new MonologExtension();
-
- $loader->load([['handlers' => ['main' => ['type' => 'fallbackgroup']]]], $container);
- }
-
/**
* @dataProvider provideLoglevelParameterConfig
*/
@@ -754,10 +650,6 @@ public function testProcessorAutoConfiguration()
*/
public function testAsMonologProcessorAutoconfigurationRedeclareMethod(): void
{
- if (!class_exists(AsMonologProcessor::class, true)) {
- $this->markTestSkipped('Monolog >= 2.3.6 is needed.');
- }
-
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('AsMonologProcessor attribute cannot declare a method on "Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\RedeclareMethodProcessor::__invoke()".');
diff --git a/composer.json b/composer.json
index 91b22061..09353645 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,7 @@
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
- "monolog/monolog": "^1.25.1 || ^2.0 || ^3.0"
+ "monolog/monolog": "^2.4 || ^3.0"
},
"require-dev": {
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",