-
-
Notifications
You must be signed in to change notification settings - Fork 240
Deprecate "mongo" handler type in favor of new "mongodb" syntax #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,6 +265,12 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler | |
| break; | ||
|
|
||
| case 'mongo': | ||
| trigger_deprecation('symfony/monolog-bundle', '3.11', 'The "mongo" handler type is deprecated in MonologBundle since version 3.11.0, use the "mongodb" type instead.'); | ||
|
|
||
| if (!class_exists('MongoDB\Client')) { | ||
| throw new \RuntimeException('The "mongo" handler requires the mongodb/mongodb package to be installed.'); | ||
| } | ||
|
|
||
| if (isset($handler['mongo']['id'])) { | ||
| $client = new Reference($handler['mongo']['id']); | ||
| } else { | ||
|
|
@@ -278,9 +284,8 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler | |
|
|
||
| $client = new Definition('MongoDB\Client', [ | ||
| $server, | ||
| ['appname' => 'monolog-bundle'], | ||
| ]); | ||
|
|
||
| $client->setPublic(false); | ||
| } | ||
|
|
||
| $definition->setArguments([ | ||
|
|
@@ -292,6 +297,44 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler | |
| ]); | ||
| break; | ||
|
|
||
| case 'mongodb': | ||
| if (!class_exists('MongoDB\Client')) { | ||
| throw new \RuntimeException('The "mongodb" handler requires the mongodb/mongodb package to be installed.'); | ||
| } | ||
|
|
||
| if (isset($handler['mongodb']['id'])) { | ||
| $client = new Reference($handler['mongodb']['id']); | ||
| } else { | ||
| $uriOptions = ['appname' => 'monolog-bundle']; | ||
|
|
||
| if (isset($handler['mongodb']['username'])) { | ||
| $uriOptions['username'] = $handler['mongodb']['username']; | ||
| } | ||
|
|
||
| if (isset($handler['mongodb']['password'])) { | ||
| $uriOptions['password'] = $handler['mongodb']['password']; | ||
| } | ||
|
|
||
| $client = new Definition('MongoDB\Client', [ | ||
| $handler['mongodb']['uri'], | ||
| $uriOptions, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That can be specified in the We can revisit when adding more options across the board.
Were you actually referring to |
||
| ]); | ||
| } | ||
|
|
||
| $definition->setArguments([ | ||
| $client, | ||
| $handler['mongodb']['database'], | ||
| $handler['mongodb']['collection'], | ||
| $handler['level'], | ||
| $handler['bubble'], | ||
| ]); | ||
|
|
||
| if (empty($handler['formatter'])) { | ||
| $formatter = new Definition('Monolog\Formatter\MongoDBFormatter'); | ||
| $definition->addMethodCall('setFormatter', [$formatter]); | ||
| } | ||
| break; | ||
|
|
||
| case 'elasticsearch': | ||
| trigger_deprecation('symfony/monolog-bundle', '3.8', 'The "elasticsearch" handler type is deprecated in MonologBundle since version 3.8.0, use the "elastica" type instead, or switch to the official Elastic client using the "elastic_search" type.'); | ||
| // no break | ||
|
|
@@ -1021,6 +1064,7 @@ private function getHandlerClassByType($handlerType) | |
| 'fingers_crossed' => 'Monolog\Handler\FingersCrossedHandler', | ||
| 'filter' => 'Monolog\Handler\FilterHandler', | ||
| 'mongo' => 'Monolog\Handler\MongoDBHandler', | ||
| 'mongodb' => 'Monolog\Handler\MongoDBHandler', | ||
| 'elasticsearch' => 'Monolog\Handler\ElasticSearchHandler', | ||
| 'telegram' => 'Monolog\Handler\TelegramBotHandler', | ||
| 'server_log' => 'Symfony\Bridge\Monolog\Handler\ServerLogHandler', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" ?> | ||
|
|
||
| <srv:container xmlns="http://symfony.com/schema/dic/monolog" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:srv="http://symfony.com/schema/dic/services" | ||
| xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
| http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"> | ||
|
|
||
| <config> | ||
| <handler name="mongodb" type="mongodb"> | ||
| <mongodb uri="mongodb://localhost:27018" username="username" password="password" database="db" collection="coll" /> | ||
| </handler> | ||
| </config> | ||
| </srv:container> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| monolog: | ||
| handlers: | ||
| mongodb: | ||
| type: mongodb | ||
| mongodb: | ||
| uri: "mongodb://localhost:27018" | ||
| username: username | ||
| password: password | ||
| database: db | ||
| collection: coll |
Uh oh!
There was an error while loading. Please reload this page.