Skip to content

Commit d62acb0

Browse files
committed
Drop support for Monolog 1
1 parent 33bf5ca commit d62acb0

12 files changed

+28
-342
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
33-
monolog: [ '1.*', '2.*' ]
33+
monolog: [ '2.*' ]
3434
include:
3535
- php: '7.4'
3636
deps: lowest

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Unreleased
22

3+
* Drop support for Monolog 1
4+
35
## 3.10.0 (2023-11-06)
46

57
* Add configuration support for SamplingHandler

DependencyInjection/Configuration.php

+12-62
Original file line numberDiff line numberDiff line change
@@ -223,38 +223,22 @@
223223
* - [timeout]: float
224224
* - [connection_timeout]: float
225225
*
226-
* - raven / sentry:
226+
* - sentry:
227227
* - dsn: connection string
228228
* - client_id: Raven client custom service id (optional)
229+
* - hub_id: Sentry hub custom service id (optional)
229230
* - [release]: release number of the application that will be attached to logs, defaults to null
230231
* - [level]: level name or int value, defaults to DEBUG
231232
* - [bubble]: bool, defaults to true
232233
* - [auto_log_stacks]: bool, defaults to false
233234
* - [environment]: string, default to null (no env specified)
234-
*
235-
* - sentry:
236-
* - hub_id: Sentry hub custom service id (optional)
237235
* - [fill_extra_context]: bool, defaults to false
238236
*
239237
* - newrelic:
240238
* - [level]: level name or int value, defaults to DEBUG
241239
* - [bubble]: bool, defaults to true
242240
* - [app_name]: new relic app name, default null
243241
*
244-
* - hipchat:
245-
* - token: hipchat api token
246-
* - room: room id or name
247-
* - [notify]: defaults to false
248-
* - [nickname]: defaults to Monolog
249-
* - [level]: level name or int value, defaults to DEBUG
250-
* - [bubble]: bool, defaults to true
251-
* - [use_ssl]: bool, defaults to true
252-
* - [message_format]: text or html, defaults to text
253-
* - [host]: defaults to "api.hipchat.com"
254-
* - [api_version]: defaults to "v1"
255-
* - [timeout]: float
256-
* - [connection_timeout]: float
257-
*
258242
* - slack:
259243
* - token: slack api token
260244
* - channel: channel name (with starting #)
@@ -279,13 +263,6 @@
279263
* - [level]: level name or int value, defaults to DEBUG
280264
* - [bubble]: bool, defaults to true
281265
*
282-
* - slackbot:
283-
* - team: slack team slug
284-
* - token: slackbot token
285-
* - channel: channel name (with starting #)
286-
* - [level]: level name or int value, defaults to DEBUG
287-
* - [bubble]: bool, defaults to true
288-
*
289266
* - cube:
290267
* - url: http/udp url to the cube server
291268
* - [level]: level name or int value, defaults to DEBUG
@@ -538,23 +515,17 @@ public function getConfigTreeBuilder(): TreeBuilder
538515
->scalarNode('url')->end() // cube
539516
->scalarNode('exchange')->end() // amqp
540517
->scalarNode('exchange_name')->defaultValue('log')->end() // amqp
541-
->scalarNode('room')->end() // hipchat
542-
->scalarNode('message_format')->defaultValue('text')->end() // hipchat
543-
->scalarNode('api_version')->defaultNull()->end() // hipchat
544-
->scalarNode('channel')->defaultNull()->end() // slack & slackwebhook & slackbot & telegram
518+
->scalarNode('channel')->defaultNull()->end() // slack & slackwebhook & telegram
545519
->scalarNode('bot_name')->defaultValue('Monolog')->end() // slack & slackwebhook
546520
->scalarNode('use_attachment')->defaultTrue()->end() // slack & slackwebhook
547521
->scalarNode('use_short_attachment')->defaultFalse()->end() // slack & slackwebhook
548522
->scalarNode('include_extra')->defaultFalse()->end() // slack & slackwebhook
549523
->scalarNode('icon_emoji')->defaultNull()->end() // slack & slackwebhook
550524
->scalarNode('webhook_url')->end() // slackwebhook
551-
->scalarNode('team')->end() // slackbot
552-
->scalarNode('notify')->defaultFalse()->end() // hipchat
553-
->scalarNode('nickname')->defaultValue('Monolog')->end() // hipchat
554-
->scalarNode('token')->end() // pushover & hipchat & loggly & logentries & flowdock & rollbar & slack & slackbot & insightops & telegram
525+
->scalarNode('token')->end() // pushover & loggly & logentries & flowdock & rollbar & slack & insightops & telegram
555526
->scalarNode('region')->end() // insightops
556527
->scalarNode('source')->end() // flowdock
557-
->booleanNode('use_ssl')->defaultTrue()->end() // logentries & hipchat & insightops
528+
->booleanNode('use_ssl')->defaultTrue()->end() // logentries & insightops
558529
->variableNode('user') // pushover
559530
->validate()
560531
->ifTrue(function ($v) {
@@ -564,7 +535,7 @@ public function getConfigTreeBuilder(): TreeBuilder
564535
->end()
565536
->end()
566537
->scalarNode('title')->defaultNull()->end() // pushover
567-
->scalarNode('host')->defaultNull()->end() // syslogudp & hipchat
538+
->scalarNode('host')->defaultNull()->end() // syslogudp
568539
->scalarNode('port')->defaultValue(514)->end() // syslogudp
569540
->arrayNode('config')
570541
->canBeUnset()
@@ -576,18 +547,17 @@ public function getConfigTreeBuilder(): TreeBuilder
576547
->prototype('scalar')->end()
577548
->end()
578549
->scalarNode('connection_string')->end() // socket_handler
579-
->scalarNode('timeout')->end() // socket_handler, logentries, pushover, hipchat & slack
550+
->scalarNode('timeout')->end() // socket_handler, logentries, pushover & slack
580551
->scalarNode('time')->defaultValue(60)->end() // deduplication
581552
->scalarNode('deduplication_level')->defaultValue(Logger::ERROR)->end() // deduplication
582553
->scalarNode('store')->defaultNull()->end() // deduplication
583-
->scalarNode('connection_timeout')->end() // socket_handler, logentries, pushover, hipchat & slack
554+
->scalarNode('connection_timeout')->end() // socket_handler, logentries, pushover & slack
584555
->booleanNode('persistent')->end() // socket_handler
585-
->scalarNode('dsn')->end() // raven_handler, sentry_handler
556+
->scalarNode('dsn')->end() // sentry_handler
586557
->scalarNode('hub_id')->defaultNull()->end() // sentry_handler
587-
->scalarNode('client_id')->defaultNull()->end() // raven_handler, sentry_handler
588-
->scalarNode('auto_log_stacks')->defaultFalse()->end() // raven_handler
589-
->scalarNode('release')->defaultNull()->end() // raven_handler, sentry_handler
590-
->scalarNode('environment')->defaultNull()->end() // raven_handler, sentry_handler
558+
->scalarNode('client_id')->defaultNull()->end() // sentry_handler
559+
->scalarNode('release')->defaultNull()->end() // sentry_handler
560+
->scalarNode('environment')->defaultNull()->end() // sentry_handler
591561
->scalarNode('message_type')->defaultValue(0)->end() // error_log
592562
->scalarNode('parse_mode')->defaultNull()->end() // telegram
593563
->booleanNode('disable_webpage_preview')->defaultNull()->end() // telegram
@@ -713,10 +683,6 @@ public function getConfigTreeBuilder(): TreeBuilder
713683
->ifTrue(function ($v) { return 'pushover' === $v['type'] && (empty($v['token']) || empty($v['user'])); })
714684
->thenInvalid('The token and user have to be specified to use a PushoverHandler')
715685
->end()
716-
->validate()
717-
->ifTrue(function ($v) { return 'raven' === $v['type'] && !\array_key_exists('dsn', $v) && null === $v['client_id']; })
718-
->thenInvalid('The DSN has to be specified to use a RavenHandler')
719-
->end()
720686
->validate()
721687
->ifTrue(function ($v) { return 'sentry' === $v['type'] && !\array_key_exists('dsn', $v) && null === $v['hub_id'] && null === $v['client_id']; })
722688
->thenInvalid('The DSN has to be specified to use Sentry\'s handler')
@@ -725,18 +691,6 @@ public function getConfigTreeBuilder(): TreeBuilder
725691
->ifTrue(function ($v) { return 'sentry' === $v['type'] && null !== $v['hub_id'] && null !== $v['client_id']; })
726692
->thenInvalid('You can not use both a hub_id and a client_id in a Sentry handler')
727693
->end()
728-
->validate()
729-
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && (empty($v['token']) || empty($v['room'])); })
730-
->thenInvalid('The token and room have to be specified to use a HipChatHandler')
731-
->end()
732-
->validate()
733-
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && !\in_array($v['message_format'], ['text', 'html']); })
734-
->thenInvalid('The message_format has to be "text" or "html" in a HipChatHandler')
735-
->end()
736-
->validate()
737-
->ifTrue(function ($v) { return 'hipchat' === $v['type'] && null !== $v['api_version'] && !\in_array($v['api_version'], ['v1', 'v2'], true); })
738-
->thenInvalid('The api_version has to be "v1" or "v2" in a HipChatHandler')
739-
->end()
740694
->validate()
741695
->ifTrue(function ($v) { return 'slack' === $v['type'] && (empty($v['token']) || empty($v['channel'])); })
742696
->thenInvalid('The token and channel have to be specified to use a SlackHandler')
@@ -745,10 +699,6 @@ public function getConfigTreeBuilder(): TreeBuilder
745699
->ifTrue(function ($v) { return 'slackwebhook' === $v['type'] && (empty($v['webhook_url'])); })
746700
->thenInvalid('The webhook_url have to be specified to use a SlackWebhookHandler')
747701
->end()
748-
->validate()
749-
->ifTrue(function ($v) { return 'slackbot' === $v['type'] && (empty($v['team']) || empty($v['token']) || empty($v['channel'])); })
750-
->thenInvalid('The team, token and channel have to be specified to use a SlackbotHandler')
751-
->end()
752702
->validate()
753703
->ifTrue(function ($v) { return 'cube' === $v['type'] && empty($v['url']); })
754704
->thenInvalid('The url has to be specified to use a CubeHandler')

DependencyInjection/MonologExtension.php

-92
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
229229

230230
$publisher = new Definition('Gelf\Publisher', []);
231231
$publisher->addMethodCall('addTransport', [$transport]);
232-
$publisher->setPublic(false);
233-
} elseif (class_exists('Gelf\MessagePublisher')) {
234-
$publisher = new Definition('Gelf\MessagePublisher', [
235-
$handler['publisher']['hostname'],
236-
$handler['publisher']['port'],
237-
$handler['publisher']['chunk_size'],
238-
]);
239-
240232
$publisher->setPublic(false);
241233
} else {
242234
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
632624
}
633625
break;
634626

635-
case 'hipchat':
636-
$definition->setArguments([
637-
$handler['token'],
638-
$handler['room'],
639-
$handler['nickname'],
640-
$handler['notify'],
641-
$handler['level'],
642-
$handler['bubble'],
643-
$handler['use_ssl'],
644-
$handler['message_format'],
645-
!empty($handler['host']) ? $handler['host'] : 'api.hipchat.com',
646-
!empty($handler['api_version']) ? $handler['api_version'] : 'v1',
647-
]);
648-
if (isset($handler['timeout'])) {
649-
$definition->addMethodCall('setTimeout', [$handler['timeout']]);
650-
}
651-
if (isset($handler['connection_timeout'])) {
652-
$definition->addMethodCall('setConnectionTimeout', [$handler['connection_timeout']]);
653-
}
654-
break;
655-
656627
case 'slack':
657628
$definition->setArguments([
658629
$handler['token'],
@@ -687,16 +658,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
687658
]);
688659
break;
689660

690-
case 'slackbot':
691-
$definition->setArguments([
692-
$handler['team'],
693-
$handler['token'],
694-
urlencode($handler['channel']),
695-
$handler['level'],
696-
$handler['bubble'],
697-
]);
698-
break;
699-
700661
case 'cube':
701662
$definition->setArguments([
702663
$handler['url'],
@@ -773,31 +734,6 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
773734
]);
774735
break;
775736

776-
case 'raven':
777-
if (null !== $handler['client_id']) {
778-
$clientId = $handler['client_id'];
779-
} else {
780-
$client = new Definition('Raven_Client', [
781-
$handler['dsn'],
782-
[
783-
'auto_log_stacks' => $handler['auto_log_stacks'],
784-
'environment' => $handler['environment'],
785-
],
786-
]);
787-
$client->setPublic(false);
788-
$clientId = 'monolog.raven.client.'.sha1($handler['dsn']);
789-
$container->setDefinition($clientId, $client);
790-
}
791-
$definition->setArguments([
792-
new Reference($clientId),
793-
$handler['level'],
794-
$handler['bubble'],
795-
]);
796-
if (!empty($handler['release'])) {
797-
$definition->addMethodCall('setRelease', [$handler['release']]);
798-
}
799-
break;
800-
801737
case 'loggly':
802738
$definition->setArguments([
803739
$handler['token'],
@@ -975,13 +911,10 @@ private function getHandlerClassByType($handlerType)
975911
'symfony_mailer' => 'Symfony\Bridge\Monolog\Handler\MailerHandler',
976912
'socket' => 'Monolog\Handler\SocketHandler',
977913
'pushover' => 'Monolog\Handler\PushoverHandler',
978-
'raven' => 'Monolog\Handler\RavenHandler',
979914
'sentry' => 'Sentry\Monolog\Handler',
980915
'newrelic' => 'Monolog\Handler\NewRelicHandler',
981-
'hipchat' => 'Monolog\Handler\HipChatHandler',
982916
'slack' => 'Monolog\Handler\SlackHandler',
983917
'slackwebhook' => 'Monolog\Handler\SlackWebhookHandler',
984-
'slackbot' => 'Monolog\Handler\SlackbotHandler',
985918
'cube' => 'Monolog\Handler\CubeHandler',
986919
'amqp' => 'Monolog\Handler\AmqpHandler',
987920
'error_log' => 'Monolog\Handler\ErrorLogHandler',
@@ -991,55 +924,30 @@ private function getHandlerClassByType($handlerType)
991924
'fingers_crossed' => 'Monolog\Handler\FingersCrossedHandler',
992925
'filter' => 'Monolog\Handler\FilterHandler',
993926
'mongo' => 'Monolog\Handler\MongoDBHandler',
994-
'elasticsearch' => 'Monolog\Handler\ElasticSearchHandler',
995927
'telegram' => 'Monolog\Handler\TelegramBotHandler',
996928
'server_log' => 'Symfony\Bridge\Monolog\Handler\ServerLogHandler',
997929
'redis' => 'Monolog\Handler\RedisHandler',
998930
'predis' => 'Monolog\Handler\RedisHandler',
999931
'insightops' => 'Monolog\Handler\InsightOpsHandler',
1000932
'sampling' => 'Monolog\Handler\SamplingHandler',
1001-
];
1002-
1003-
$v2HandlerTypesAdded = [
1004933
'elastica' => 'Monolog\Handler\ElasticaHandler',
1005934
'elasticsearch' => 'Monolog\Handler\ElasticaHandler',
1006935
'elastic_search' => 'Monolog\Handler\ElasticsearchHandler',
1007936
'fallbackgroup' => 'Monolog\Handler\FallbackGroupHandler',
1008937
'noop' => 'Monolog\Handler\NoopHandler',
1009938
];
1010939

1011-
$v2HandlerTypesRemoved = [
1012-
'hipchat',
1013-
'raven',
1014-
'slackbot',
1015-
];
1016-
1017940
$v3HandlerTypesRemoved = [
1018941
'swift_mailer',
1019942
];
1020943

1021-
if (Logger::API >= 2) {
1022-
$typeToClassMapping = array_merge($typeToClassMapping, $v2HandlerTypesAdded);
1023-
foreach ($v2HandlerTypesRemoved as $v2HandlerTypeRemoved) {
1024-
unset($typeToClassMapping[$v2HandlerTypeRemoved]);
1025-
}
1026-
}
1027-
1028944
if (Logger::API >= 3) {
1029945
foreach ($v3HandlerTypesRemoved as $v3HandlerTypeRemoved) {
1030946
unset($typeToClassMapping[$v3HandlerTypeRemoved]);
1031947
}
1032948
}
1033949

1034950
if (!isset($typeToClassMapping[$handlerType])) {
1035-
if (Logger::API === 1 && \array_key_exists($handlerType, $v2HandlerTypesAdded)) {
1036-
throw new \InvalidArgumentException(\sprintf('"%s" was added in Monolog v2, please upgrade if you wish to use it.', $handlerType));
1037-
}
1038-
1039-
if (Logger::API >= 2 && \array_key_exists($handlerType, $v2HandlerTypesRemoved)) {
1040-
throw new \InvalidArgumentException(\sprintf('"%s" was removed in Monolog v2.', $handlerType));
1041-
}
1042-
1043951
if (Logger::API >= 3 && \array_key_exists($handlerType, $v3HandlerTypesRemoved)) {
1044952
throw new \InvalidArgumentException(\sprintf('"%s" was removed in Monolog v3.', $handlerType));
1045953
}

Resources/config/schema/monolog-1.0.xsd

-5
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
<xsd:attribute name="from-email" type="xsd:string" />
5858
<xsd:attribute name="to-email" type="xsd:string" />
5959
<xsd:attribute name="subject" type="xsd:string" />
60-
<xsd:attribute name="notify" type="xsd:boolean" />
61-
<xsd:attribute name="room" type="xsd:string" />
62-
<xsd:attribute name="nickname" type="xsd:string" />
6360
<xsd:attribute name="release" type="xsd:string" />
6461
<xsd:attribute name="timeout" type="xsd:string" />
6562
<xsd:attribute name="time" type="xsd:integer" />
@@ -86,11 +83,9 @@
8683
<xsd:attribute name="document_type" type="xsd:string" />
8784
<xsd:attribute name="document-type" type="xsd:string" />
8885
<xsd:attribute name="ignore-error" type="xsd:string" />
89-
<xsd:attribute name="api_version" type="xsd:string" />
9086
<xsd:attribute name="include-stacktraces" type="xsd:string" />
9187
<xsd:attribute name="content-type" type="xsd:string" />
9288
<xsd:attribute name="webhook-url" type="xsd:string" />
93-
<xsd:attribute name="slack-team" type="xsd:string" />
9489
<xsd:attribute name="region" type="xsd:string" />
9590
</xsd:complexType>
9691

Tests/DependencyInjection/Compiler/AddProcessorsPassTest.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Compiler;
1313

1414
use Monolog\Handler\NullHandler;
15-
use Monolog\Logger;
1615
use PHPUnit\Framework\TestCase;
1716
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
1817
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddProcessorsPass;
@@ -53,16 +52,9 @@ public function testFailureOnHandlerWithoutPushProcessor()
5352
$container->getCompilerPassConfig()->setRemovingPasses([]);
5453
$container->addCompilerPass(new AddProcessorsPass());
5554

56-
if (Logger::API < 2) {
57-
$container->compile();
58-
$service = $container->getDefinition('monolog.handler.test3');
59-
$calls = $service->getMethodCalls();
60-
$this->assertCount(1, $calls);
61-
} else {
62-
$this->expectException(\InvalidArgumentException::class);
63-
$this->expectExceptionMessage('The "test3" handler does not accept processors');
64-
$container->compile();
65-
}
55+
$this->expectException(\InvalidArgumentException::class);
56+
$this->expectExceptionMessage('The "test3" handler does not accept processors');
57+
$container->compile();
6658
}
6759

6860
protected function getContainer()

0 commit comments

Comments
 (0)