@@ -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. ' , true );
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 (
324
+ $ activationDef = new Definition ('Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy ' , array (
324
325
new Reference ('request_stack ' ),
325
326
$ handler ['excluded_404s ' ],
326
327
$ handler ['action_level ' ]
@@ -696,4 +697,52 @@ private function getHandlerId($name)
696
697
{
697
698
return sprintf ('monolog.handler.%s ' , $ name );
698
699
}
700
+
701
+ private function getHandlerClassByType ($ handlerType )
702
+ {
703
+ $ typeToClassMapping = array (
704
+ 'stream ' => 'Monolog\Handler\StreamHandler ' ,
705
+ 'console ' => 'Symfony\Bridge\Monolog\Handler\ConsoleHandler ' ,
706
+ 'group ' => 'Monolog\Handler\GroupHandler ' ,
707
+ 'buffer ' => 'Monolog\Handler\BufferHandler ' ,
708
+ 'deduplication ' => 'Monolog\Handler\DeduplicationHandler ' ,
709
+ 'rotating_file ' => 'Monolog\Handler\RotatingFileHandler ' ,
710
+ 'syslog ' => 'Monolog\Handler\SyslogHandler ' ,
711
+ 'syslogudp ' => 'Monolog\Handler\SyslogUdpHandler ' ,
712
+ 'null ' => 'Monolog\Handler\NullHandler ' ,
713
+ 'test ' => 'Monolog\Handler\TestHandler ' ,
714
+ 'gelf ' => 'Monolog\Handler\GelfHandler ' ,
715
+ 'rollbar ' => 'Monolog\Handler\RollbarHandler ' ,
716
+ 'flowdock ' => 'Monolog\Handler\FlowdockHandler ' ,
717
+ 'browser_console ' => 'Monolog\Handler\BrowserConsoleHandler ' ,
718
+ 'firephp ' => 'Symfony\Bridge\Monolog\Handler\FirePHPHandler ' ,
719
+ 'chromephp ' => 'Symfony\Bridge\Monolog\Handler\ChromePhpHandler ' ,
720
+ 'debug ' => 'Symfony\Bridge\Monolog\Handler\DebugHandler ' ,
721
+ 'swift_mailer ' => 'Symfony\Bridge\Monolog\Handler\SwiftMailerHandler ' ,
722
+ 'native_mailer ' => 'Monolog\Handler\NativeMailerHandler ' ,
723
+ 'socket ' => 'Monolog\Handler\SocketHandler ' ,
724
+ 'pushover ' => 'Monolog\Handler\PushoverHandler ' ,
725
+ 'raven ' => 'Monolog\Handler\RavenHandler ' ,
726
+ 'newrelic ' => 'Monolog\Handler\NewRelicHandler ' ,
727
+ 'hipchat ' => 'Monolog\Handler\HipChatHandler ' ,
728
+ 'slack ' => 'Monolog\Handler\SlackHandler ' ,
729
+ 'cube ' => 'Monolog\Handler\CubeHandler ' ,
730
+ 'amqp ' => 'Monolog\Handler\AmqpHandler ' ,
731
+ 'error_log ' => 'Monolog\Handler\ErrorLogHandler ' ,
732
+ 'loggly ' => 'Monolog\Handler\LogglyHandler ' ,
733
+ 'logentries ' => 'Monolog\Handler\LogEntriesHandler ' ,
734
+ 'whatfailuregroup ' => 'Monolog\Handler\WhatFailureGroupHandler ' ,
735
+ 'fingers_crossed ' => 'Monolog\Handler\FingersCrossedHandler ' ,
736
+ 'filter ' => 'Monolog\Handler\FilterHandler ' ,
737
+ 'mongo ' => 'Monolog\Handler\MongoDBHandler ' ,
738
+ 'elasticsearch ' => 'Monolog\Handler\ElasticSearchHandler ' ,
739
+ );
740
+
741
+ if (!isset ($ typeToClassMapping [$ handlerType ])) {
742
+ throw new \InvalidArgumentException (sprintf ('There is no handler class defined for handler "%s". ' , $ handlerType ));
743
+ }
744
+
745
+ return $ typeToClassMapping [$ handlerType ];
746
+ }
747
+
699
748
}
0 commit comments