@@ -130,7 +130,8 @@ public function getNamespace()
130
130
private function buildHandler (ContainerBuilder $ container , $ name , array $ handler )
131
131
{
132
132
$ handlerId = $ this ->getHandlerId ($ name );
133
- $ definition = new Definition (sprintf ('%%monolog.handler.%s.class%% ' , $ handler ['type ' ]));
133
+ $ definition = new Definition ($ this ->getHandlerClassByType ($ handler ['type ' ]));
134
+
134
135
$ handler ['level ' ] = $ this ->levelToMonologConst ($ handler ['level ' ]);
135
136
136
137
if ($ handler ['include_stacktraces ' ]) {
@@ -186,13 +187,13 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
186
187
$ transport ->setPublic (false );
187
188
$ container ->setDefinition ($ transportId , $ transport );
188
189
189
- $ publisher = new Definition ('%monolog.gelfphp.publisher.class% ' , array ());
190
+ $ publisher = new Definition ('Gelf\Publisher ' , array ());
190
191
$ publisher ->addMethodCall ('addTransport ' , array (new Reference ($ transportId )));
191
192
$ publisherId = uniqid ('monolog.gelf.publisher. ' );
192
193
$ publisher ->setPublic (false );
193
194
$ container ->setDefinition ($ publisherId , $ publisher );
194
195
} elseif (class_exists ('Gelf\MessagePublisher ' )) {
195
- $ publisher = new Definition ('%monolog.gelf.publisher.class% ' , array (
196
+ $ publisher = new Definition ('Gelf\MessagePublisher ' , array (
196
197
$ handler ['publisher ' ]['hostname ' ],
197
198
$ handler ['publisher ' ]['port ' ],
198
199
$ handler ['publisher ' ]['chunk_size ' ],
@@ -224,7 +225,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
224
225
225
226
$ server .= $ handler ['mongo ' ]['host ' ].': ' .$ handler ['mongo ' ]['port ' ];
226
227
227
- $ client = new Definition ('%monolog.mongo.client.class% ' , array (
228
+ $ client = new Definition ('MongoClient ' , array (
228
229
$ server ,
229
230
));
230
231
@@ -247,7 +248,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
247
248
$ clientId = $ handler ['elasticsearch ' ]['id ' ];
248
249
} else {
249
250
// elastica client new definition
250
- $ elasticaClient = new Definition ('%monolog.elastica.client.class% ' );
251
+ $ elasticaClient = new Definition ('Elastica\Client ' );
251
252
$ elasticaClientArguments = array (
252
253
'host ' => $ handler ['elasticsearch ' ]['host ' ],
253
254
'port ' => $ handler ['elasticsearch ' ]['port ' ],
@@ -320,7 +321,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
320
321
if (isset ($ handler ['activation_strategy ' ])) {
321
322
$ activation = new Reference ($ handler ['activation_strategy ' ]);
322
323
} elseif (!empty ($ handler ['excluded_404s ' ])) {
323
- $ activationDef = new Definition ('%monolog.activation_strategy.not_found.class% ' , array ($ handler ['excluded_404s ' ], $ handler ['action_level ' ]));
324
+ $ activationDef = new Definition ('Symfony\Bundle\MonologBundle\NotFoundActivationStrategy ' , array ($ handler ['excluded_404s ' ], $ handler ['action_level ' ]));
324
325
$ activationDef ->addMethodCall ('setRequest ' , array (new Reference ('request ' , ContainerInterface::NULL_ON_INVALID_REFERENCE , false )));
325
326
$ container ->setDefinition ($ handlerId .'.not_found_strategy ' , $ activationDef );
326
327
$ activation = new Reference ($ handlerId .'.not_found_strategy ' );
@@ -693,4 +694,52 @@ private function getHandlerId($name)
693
694
{
694
695
return sprintf ('monolog.handler.%s ' , $ name );
695
696
}
697
+
698
+ private function getHandlerClassByType ($ handlerType )
699
+ {
700
+ $ typeToClassMapping = array (
701
+ 'stream ' => 'Monolog\Handler\StreamHandler ' ,
702
+ 'console ' => 'Symfony\Bridge\Monolog\Handler\ConsoleHandler ' ,
703
+ 'group ' => 'Monolog\Handler\GroupHandler ' ,
704
+ 'buffer ' => 'Monolog\Handler\BufferHandler ' ,
705
+ 'deduplication ' => 'Monolog\Handler\DeduplicationHandler ' ,
706
+ 'rotating_file ' => 'Monolog\Handler\RotatingFileHandler ' ,
707
+ 'syslog ' => 'Monolog\Handler\SyslogHandler ' ,
708
+ 'syslogudp ' => 'Monolog\Handler\SyslogUdpHandler ' ,
709
+ 'null ' => 'Monolog\Handler\NullHandler ' ,
710
+ 'test ' => 'Monolog\Handler\TestHandler ' ,
711
+ 'gelf ' => 'Monolog\Handler\GelfHandler ' ,
712
+ 'rollbar ' => 'Monolog\Handler\RollbarHandler ' ,
713
+ 'flowdock ' => 'Monolog\Handler\FlowdockHandler ' ,
714
+ 'browser_console ' => 'Monolog\Handler\BrowserConsoleHandler ' ,
715
+ 'firephp ' => 'Symfony\Bridge\Monolog\Handler\FirePHPHandler ' ,
716
+ 'chromephp ' => 'Symfony\Bridge\Monolog\Handler\ChromePhpHandler ' ,
717
+ 'debug ' => 'Symfony\Bridge\Monolog\Handler\DebugHandler ' ,
718
+ 'swift_mailer ' => 'Symfony\Bridge\Monolog\Handler\SwiftMailerHandler ' ,
719
+ 'native_mailer ' => 'Monolog\Handler\NativeMailerHandler ' ,
720
+ 'socket ' => 'Monolog\Handler\SocketHandler ' ,
721
+ 'pushover ' => 'Monolog\Handler\PushoverHandler ' ,
722
+ 'raven ' => 'Monolog\Handler\RavenHandler ' ,
723
+ 'newrelic ' => 'Monolog\Handler\NewRelicHandler ' ,
724
+ 'hipchat ' => 'Monolog\Handler\HipChatHandler ' ,
725
+ 'slack ' => 'Monolog\Handler\SlackHandler ' ,
726
+ 'cube ' => 'Monolog\Handler\CubeHandler ' ,
727
+ 'amqp ' => 'Monolog\Handler\AmqpHandler ' ,
728
+ 'error_log ' => 'Monolog\Handler\ErrorLogHandler ' ,
729
+ 'loggly ' => 'Monolog\Handler\LogglyHandler ' ,
730
+ 'logentries ' => 'Monolog\Handler\LogEntriesHandler ' ,
731
+ 'whatfailuregroup ' => 'Monolog\Handler\WhatFailureGroupHandler ' ,
732
+ 'fingers_crossed ' => 'Monolog\Handler\FingersCrossedHandler ' ,
733
+ 'filter ' => 'Monolog\Handler\FilterHandler ' ,
734
+ 'mongo ' => 'Monolog\Handler\MongoDBHandler ' ,
735
+ 'elasticsearch ' => 'Monolog\Handler\ElasticSearchHandler ' ,
736
+ );
737
+
738
+ if (!isset ($ typeToClassMapping [$ handlerType ])) {
739
+ throw new \InvalidArgumentException (sprintf ('There is no handler class defined for handler "%s". ' , $ handlerType ));
740
+ }
741
+
742
+ return $ typeToClassMapping [$ handlerType ];
743
+ }
744
+
696
745
}
0 commit comments