diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 09a856f2..72646416 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -105,7 +105,7 @@
*
* - fingers_crossed:
* - handler: the wrapped handler's name
- * - [action_level|activation_strategy]: minimum level or service id to activate the handler, defaults to WARNING
+ * - [action_level|activation_strategy]: minimum level or service id to activate the handler, defaults to null
* - [excluded_404s]: if set, the strategy will be changed to one that excludes 404s coming from URLs matching any of those patterns
* - [excluded_http_codes]: if set, the strategy will be changed to one that excludes specific HTTP codes (requires Symfony Monolog bridge 4.1+)
* - [buffer_size]: defaults to 0 (unlimited)
@@ -328,6 +328,106 @@
*/
class Configuration implements ConfigurationInterface
{
+ private $acceptedParamsByHandlerType = [
+ 'stream' => ['path', 'level', 'bubble', 'file_permission', 'use_locking'],
+ 'console' => ['verbosity_levels', 'level', 'bubble', 'console_formater_options'],
+ 'firephp' => ['bubble', 'level'],
+ 'browser_console' => ['bubble', 'level'],
+ 'gelf' => ['publisher', 'bubble', 'level'],
+ 'chromephp' => ['bubble', 'level'],
+ 'rotating_file' => ['path', 'max_files', 'level', 'bubble', 'file_permission', 'filename_format', 'date_format'],
+ 'mongo' => ['mongo', 'level', 'bubble'],
+ 'elasticsearch' => ['elasticsearch', 'index', 'document_type', 'level', 'bubble'],
+ 'redis' => ['redis'],
+ 'predis' => ['redis'],
+ 'fingers_crossed' => [
+ 'handler',
+ 'action_level',
+ 'activation_strategy',
+ 'excluded_404s',
+ 'excluded_http_codes',
+ 'buffer_size',
+ 'stop_buffering',
+ 'passthru_level',
+ 'bubble'
+ ],
+ 'filter' => ['handler', 'accepted_levels', 'min_level', 'max_level', 'bubble'],
+ 'buffer' => ['handler', 'buffer_size', 'level', 'bubble', 'flush_on_overflow'],
+ 'deduplication' => ['handler', 'store', 'deduplication_level', 'time', 'bubble'],
+ 'group' => ['members', 'bubble'],
+ 'whatfailuregroup' => ['members', 'bubble'],
+ 'syslog' => ['ident', 'facility', 'logopts', 'level', 'bubble'],
+ 'syslogudp' => ['host', 'port', 'facility', 'logopts', 'level', 'bubble', 'ident'],
+ 'swift_mailer' => [
+ 'from_email',
+ 'to_email',
+ 'subject',
+ 'email_prototype',
+ 'content_type',
+ 'mailer',
+ 'level',
+ 'bubble',
+ 'lazy'
+ ],
+ 'native_mailer' => ['from_email', 'to_email', 'subject', 'level', 'bubble', 'headers'],
+ 'socket' => ['connection_string', 'timeout', 'connection_timeout', 'persistent', 'level', 'bubble'],
+ 'pushover' => ['token', 'user', 'title', 'level', 'bubble', 'timeout', 'connection_timeout'],
+ 'raven' => ['dsn', 'client_id', 'release', 'level', 'bubble', 'auto_log_stacks', 'environment'],
+ 'sentry' => ['dsn', 'client_id', 'release', 'level', 'bubble', 'auto_log_stacks', 'environment'],
+ 'newrelic' => ['level', 'bubble', 'app_name'],
+ 'hipchat' => [
+ 'token',
+ 'room',
+ 'notify',
+ 'nickname',
+ 'level',
+ 'bubble',
+ 'use_ssl',
+ 'message_format',
+ 'host',
+ 'api_version',
+ 'timeout',
+ 'connection_timeout'
+ ],
+ 'slack' => [
+ 'token',
+ 'channel',
+ 'bot_name',
+ 'icon_emoji',
+ 'use_attachment',
+ 'use_short_attachment',
+ 'include_extra',
+ 'level',
+ 'bubble',
+ 'timeout',
+ 'connection_timeout'
+ ],
+ 'slackwebhook' => [
+ 'webhook_url',
+ 'channel',
+ 'bot_name',
+ 'icon_emoji',
+ 'use_attachment',
+ 'use_short_attachment',
+ 'include_extra',
+ 'level',
+ 'bubble'
+ ],
+ 'slackbot' => ['team', 'token', 'channel', 'level', 'bubble'],
+ 'cube' => ['url', 'level', 'bubble'],
+ 'amqp' => ['exchange', 'exchange_name', 'level', 'bubble'],
+ 'error_log' => ['message_type', 'level', 'bubble'],
+ 'null' => ['level', 'bubble'],
+ 'test' => ['level', 'bubble'],
+ 'debug' => ['level', 'bubble'],
+ 'loggly' => ['token', 'level', 'bubble', 'tags'],
+ 'logentries' => ['token', 'use_ssl', 'level', 'bubble', 'timeout', 'connection_timeout'],
+ 'insightops' => ['token', 'region', 'use_ssl', 'level', 'bubble'],
+ 'flowdock' => ['token', 'source', 'from_email', 'level', 'bubble'],
+ 'rollbar' => ['id', 'token', 'config', 'level', 'bubble'],
+ 'server_log' => ['host', 'level', 'bubble'],
+ ];
+
/**
* Generates the configuration tree builder.
*
@@ -774,6 +874,10 @@ public function getConfigTreeBuilder()
->scalarNode('formatter')->end()
->booleanNode('nested')->defaultFalse()->end()
->end()
+ ->beforeNormalization()
+ ->always()
+ ->then(function ($v) { return $this->handlerTypeAcceptedOptionsValidation($v); })
+ ->end()
->validate()
->ifTrue(function ($v) { return 'service' === $v['type'] && !empty($v['formatter']); })
->thenInvalid('Service handlers can not have a formatter configured in the bundle, you must reconfigure the service itself instead')
@@ -794,10 +898,6 @@ public function getConfigTreeBuilder()
->ifTrue(function ($v) { return 'fingers_crossed' === $v['type'] && !empty($v['excluded_http_codes']) && !empty($v['excluded_404s']); })
->thenInvalid('You can not use excluded_http_codes together with excluded_404s in a FingersCrossedHandler')
->end()
- ->validate()
- ->ifTrue(function ($v) { return 'fingers_crossed' !== $v['type'] && (!empty($v['excluded_http_codes']) || !empty($v['excluded_404s'])); })
- ->thenInvalid('You can only use excluded_http_codes/excluded_404s with a FingersCrossedHandler definition')
- ->end()
->validate()
->ifTrue(function ($v) { return 'filter' === $v['type'] && "DEBUG" !== $v['min_level'] && !empty($v['accepted_levels']); })
->thenInvalid('You can not use min_level together with accepted_levels in a FilterHandler')
@@ -963,4 +1063,41 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}
+
+ private function handlerTypeAcceptedOptionsValidation(array $v)
+ {
+ if (!array_key_exists('type', $v)) {
+ return $v;
+ }
+
+// @todo add again, eventually, if we want to raise exception on next if statement
+// if (in_array($v['type'], ['config', 'id', 'service'])) {
+// return $v;
+// }
+
+ if (!array_key_exists($v['type'], $this->acceptedParamsByHandlerType)) {
+ return $v;
+ }
+
+ $acceptableParamsForHandlers = array_intersect($this->provideAllConfigurationParams(), array_keys($v));
+ $unacceptableParamForHandler = array_diff(
+ $acceptableParamsForHandlers,
+ $this->acceptedParamsByHandlerType[$v['type']]
+ );
+ if (!empty($unacceptableParamForHandler)) {
+ throw new InvalidConfigurationException(sprintf(
+ 'The handler type %s does not support %s %s',
+ strtolower($v['type']),
+ implode(', ', $unacceptableParamForHandler),
+ count($unacceptableParamForHandler) == 1 ? 'parameter' : 'parameters'
+ ));
+ }
+
+ return $v;
+ }
+
+ private function provideAllConfigurationParams()
+ {
+ return array_unique(call_user_func_array('array_merge', $this->acceptedParamsByHandlerType));
+ }
}
diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php
index 793dbbe2..2baff18d 100644
--- a/Tests/DependencyInjection/ConfigurationTest.php
+++ b/Tests/DependencyInjection/ConfigurationTest.php
@@ -172,7 +172,7 @@ public function testMergingInvalidChannels()
[
'handlers' => [
'foo' => [
- 'type' => 'stream',
+ 'type' => 'slack',
'path' => '/foo',
'channels' => 'A',
]
@@ -420,4 +420,791 @@ protected function process($configs)
return $processor->processConfiguration(new Configuration(), $configs);
}
+
+ /**
+ * @dataProvider provideHandlersConfigurations
+ */
+ public function testHandlerValidConfiguration($config)
+ {
+ $config = $this->process([$config]);
+
+ $this->assertArrayHasKey('handlers', $config);
+ }
+
+ public function provideHandlersConfigurations()
+ {
+ return
+ [
+ [
+ ['handlers' => $this->getHandlersConfigurations()]
+ ]
+ ];
+ }
+
+ private function getHandlersConfigurations()
+ {
+ $allConfigParams = $this->provideAllHandlersConfigurationParams();
+
+ return [
+ 'stream' => [
+ 'type' => 'stream',
+ 'path' => $allConfigParams['path'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'file_permission' => $allConfigParams['file_permission'],
+ 'use_locking' => $allConfigParams['use_locking'],
+ ],
+ 'console' => [
+ 'type' => 'console',
+ 'verbosity_levels' => $allConfigParams['verbosity_levels'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'console_formater_options' => $allConfigParams['console_formater_options'],
+ ],
+ 'firephp' => [
+ 'type' => 'firephp',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'browser_console' => [
+ 'type' => 'browser_console',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'gelf' => [
+ 'type' => 'gelf',
+ 'publisher' => $allConfigParams['publisher'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'chromephp' => [
+ 'type' => 'chromephp',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'rotating_file' => [
+ 'type' => 'rotating_file',
+ 'path' => $allConfigParams['path'],
+ 'max_files' => $allConfigParams['max_files'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'file_permission' => $allConfigParams['file_permission'],
+ 'filename_format' => $allConfigParams['filename_format'],
+ 'date_format' => $allConfigParams['date_format'],
+ ],
+ 'mongo' => [
+ 'type' => 'mongo',
+ 'mongo' => $allConfigParams['mongo'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'elasticsearch' => [
+ 'type' => 'elasticsearch',
+ 'elasticsearch' => $allConfigParams['elasticsearch'],
+ 'index' => $allConfigParams['index'],
+ 'document_type' => $allConfigParams['document_type'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'redis' => [
+ 'type' => 'redis',
+ 'redis' => $allConfigParams['redis'],
+ ],
+ 'predis' => [
+ 'type' => 'predis',
+ 'redis' => $allConfigParams['redis'],
+ ],
+// 'fingers_crossed' => [
+// 'type' => 'fingers_crossed',
+// 'handler' => $allConfigParams['handler'],
+// 'action_level' => $allConfigParams['action_level'],
+// 'excluded_http_codes' => $allConfigParams['excluded_http_codes'],
+// 'buffer_size' => $allConfigParams['buffer_size'],
+// 'stop_buffering' => $allConfigParams['stop_buffering'],
+// 'passthru_level' => $allConfigParams['passthru_level'],
+// 'bubble' => $allConfigParams['bubble'],
+// ],
+// 'filter' => [
+// 'type' => 'filter',
+// 'handler' => $allConfigParams['handler'],
+// 'accepted_levels' => $allConfigParams['accepted_levels'],
+// 'min_level' => $allConfigParams['min_level'],
+// 'max_level' => $allConfigParams['max_level'],
+// 'bubble' => $allConfigParams['bubble'],
+// ],
+ 'buffer' => [
+ 'type' => 'buffer',
+ 'handler' => $allConfigParams['handler'],
+ 'buffer_size' => $allConfigParams['buffer_size'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'flush_on_overflow' => $allConfigParams['flush_on_overflow'],
+ ],
+ 'deduplication' => [
+ 'type' => 'deduplication',
+ 'handler' => $allConfigParams['handler'],
+ 'store' => $allConfigParams['store'],
+ 'deduplication_level' => $allConfigParams['deduplication_level'],
+ 'time' => $allConfigParams['time'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'group' => [
+ 'type' => 'group',
+ 'members' => $allConfigParams['members'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'whatfailuregroup' => [
+ 'type' => 'whatfailuregroup',
+ 'members' => $allConfigParams['members'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'syslog' => [
+ 'type' => 'syslog',
+ 'ident' => $allConfigParams['ident'],
+ 'facility' => $allConfigParams['facility'],
+ 'logopts' => $allConfigParams['logopts'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'syslogudp' => [
+ 'type' => 'syslogudp',
+ 'host' => $allConfigParams['host'],
+ 'port' => $allConfigParams['port'],
+ 'facility' => $allConfigParams['facility'],
+ 'logopts' => $allConfigParams['logopts'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'ident' => $allConfigParams['ident'],
+ ],
+ 'swift_mailer' => [
+ 'type' => 'swift_mailer',
+ 'from_email' => $allConfigParams['from_email'],
+ 'to_email' => $allConfigParams['to_email'],
+ 'subject' => $allConfigParams['subject'],
+ 'email_prototype' => $allConfigParams['email_prototype'],
+ 'content_type' => $allConfigParams['content_type'],
+ 'mailer' => $allConfigParams['mailer'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'lazy' => $allConfigParams['lazy'],
+ ],
+ 'native_mailer' => [
+ 'type' => 'native_mailer',
+ 'from_email' => $allConfigParams['from_email'],
+ 'to_email' => $allConfigParams['to_email'],
+ 'subject' => $allConfigParams['subject'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'headers' => $allConfigParams['headers'],
+ ],
+ 'socket' => [
+ 'type' => 'socket',
+ 'connection_string' => $allConfigParams['connection_string'],
+ 'timeout' => $allConfigParams['timeout'],
+ 'connection_timeout' => $allConfigParams['connection_timeout'],
+ 'persistent' => $allConfigParams['persistent'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'pushover' => [
+ 'type' => 'pushover',
+ 'token' => $allConfigParams['token'],
+ 'user' => $allConfigParams['user'],
+ 'title' => $allConfigParams['title'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'timeout' => $allConfigParams['timeout'],
+ 'connection_timeout' => $allConfigParams['connection_timeout'],
+ ],
+ 'raven' => [
+ 'type' => 'raven',
+ 'dsn' => $allConfigParams['dsn'],
+ 'client_id' => $allConfigParams['client_id'],
+ 'release' => $allConfigParams['release'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'auto_log_stacks' => $allConfigParams['auto_log_stacks'],
+ 'environment' => $allConfigParams['environment'],
+ ],
+ 'sentry' => [
+ 'type' => 'sentry',
+ 'dsn' => $allConfigParams['dsn'],
+ 'client_id' => $allConfigParams['client_id'],
+ 'release' => $allConfigParams['release'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'auto_log_stacks' => $allConfigParams['auto_log_stacks'],
+ 'environment' => $allConfigParams['environment'],
+ ],
+ 'newrelic' => [
+ 'type' => 'newrelic',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'app_name' => $allConfigParams['app_name'],
+ ],
+ 'hipchat' => [
+ 'type' => 'hipchat',
+ 'token' => $allConfigParams['token'],
+ 'room' => $allConfigParams['room'],
+ 'notify' => $allConfigParams['notify'],
+ 'nickname' => $allConfigParams['nickname'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'use_ssl' => $allConfigParams['use_ssl'],
+ 'message_format' => $allConfigParams['message_format'],
+ 'host' => $allConfigParams['host'],
+ 'api_version' => $allConfigParams['api_version'],
+ 'timeout' => $allConfigParams['timeout'],
+ 'connection_timeout' => $allConfigParams['connection_timeout'],
+ ],
+ 'slack' => [
+ 'type' => 'slack',
+ 'token' => $allConfigParams['token'],
+ 'channel' => $allConfigParams['channel'],
+ 'bot_name' => $allConfigParams['bot_name'],
+ 'icon_emoji' => $allConfigParams['icon_emoji'],
+ 'use_attachment' => $allConfigParams['use_attachment'],
+ 'use_short_attachment' => $allConfigParams['use_short_attachment'],
+ 'include_extra' => $allConfigParams['include_extra'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'timeout' => $allConfigParams['timeout'],
+ 'connection_timeout' => $allConfigParams['connection_timeout'],
+ ],
+ 'slackwebhook' => [
+ 'type' => 'slackwebhook',
+ 'webhook_url' => $allConfigParams['webhook_url'],
+ 'channel' => $allConfigParams['channel'],
+ 'bot_name' => $allConfigParams['bot_name'],
+ 'icon_emoji' => $allConfigParams['icon_emoji'],
+ 'use_attachment' => $allConfigParams['use_attachment'],
+ 'use_short_attachment' => $allConfigParams['use_short_attachment'],
+ 'include_extra' => $allConfigParams['include_extra'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'slackbot' => [
+ 'type' => 'slackbot',
+ 'team' => $allConfigParams['team'],
+ 'token' => $allConfigParams['token'],
+ 'channel' => $allConfigParams['channel'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'cube' => [
+ 'type' => 'cube',
+ 'url' => $allConfigParams['url'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'amqp' => [
+ 'type' => 'amqp',
+ 'exchange' => $allConfigParams['exchange'],
+ 'exchange_name' => $allConfigParams['exchange_name'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'error_log' => [
+ 'type' => 'error_log',
+ 'message_type' => $allConfigParams['message_type'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'null' => [
+ 'type' => 'null',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'test' => [
+ 'type' => 'test',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'deb' => [
+ 'type' => 'debug',
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'loggly' => [
+ 'type' => 'loggly',
+ 'token' => $allConfigParams['token'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'tags' => $allConfigParams['tags'],
+ ],
+ 'logentries' => [
+ 'type' => 'logentries',
+ 'token' => $allConfigParams['token'],
+ 'use_ssl' => $allConfigParams['use_ssl'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ 'timeout' => $allConfigParams['timeout'],
+ 'connection_timeout' => $allConfigParams['connection_timeout'],
+ ],
+ 'insightops' => [
+ 'type' => 'insightops',
+ 'token' => $allConfigParams['token'],
+ 'region' => $allConfigParams['region'],
+ 'use_ssl' => $allConfigParams['use_ssl'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+ 'flowdock' => [
+ 'type' => 'flowdock',
+ 'token' => $allConfigParams['token'],
+ 'source' => $allConfigParams['source'],
+ 'from_email' => $allConfigParams['from_email'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ],
+// 'rollbar' => [
+// 'type' => 'rollbar',
+// 'id' => $allConfigParams['id'],
+// 'token' => $allConfigParams['token'],
+// 'config' => $allConfigParams['config'],
+// 'level' => $allConfigParams['level'],
+// 'bubble' => $allConfigParams['bubble'],
+// ]
+ 'server_log' => [
+ 'type' => 'server_log',
+ 'host' => $allConfigParams['host'],
+ 'level' => $allConfigParams['level'],
+ 'bubble' => $allConfigParams['bubble'],
+ ]
+ ];
+ }
+
+ private function provideAllHandlersConfigurationParams()
+ {
+ return [
+ 'accepted_levels' => ['DEBUG'],
+ 'action_level' => 'DEBUG',
+ 'activation_strategy' => 'DEBUG',
+ 'api_version' => 'v2',
+ 'app_name' => 'app_name',
+ 'auto_log_stacks' => true,
+ 'bubble' => false,
+ 'bot_name' => 'bot_name',
+ 'buffer_size' => 0,
+ 'channel' => '#channel_name',
+ 'client_id' => 'client_id',
+ 'config' => ['config' => 'config'],
+ 'connection_string' => 'connection_string',
+ 'connection_timeout' => 0.5,
+ 'console_formater_options' => [],
+ 'content_type' => 'text/plain',
+ 'date_format' => 'Y-m-d',
+ 'deduplication_level' => 'DEBUG',
+ 'document_type' => 'logs',
+ 'dsn' => 'dsn_connection_string',
+ 'elasticsearch' => 'id',
+ 'email_prototype' => 'service_message_id',
+ 'environment' => 'dev',
+ 'exchange' => 'service_id',
+ 'exchange_name' => 'log',
+ 'excluded_404s' => ['^/.*'],
+ 'excluded_http_codes' => [404],
+ 'facility' => 'user',
+ 'filename_format' => 'filename_format',
+ 'file_permission' => 777,
+ 'flush_on_overflow' => true,
+ 'from_email' => 'fromemail@test.com',
+ 'handler' => 'handler_name',
+ 'headers' => ['Foo: Bar'],
+ 'host' => 'hostname',
+ 'icon_emoji' => ':icon_emoji:',
+ 'id' => 'id',
+ 'ident' => 'ident',
+ 'include_extra' => true,
+ 'index' => 'monolog',
+ 'lazy' => false,
+ 'level' => 'DEBUG',
+ 'logopts' => 'LOGPID',
+ 'mailer' => 'mailer',
+ 'max_files' => 0,
+ 'max_level' => 'DEBUG',
+ 'message_format' => 'html',
+ 'message_type' => '1',
+ 'min_level' => 'DEBUG',
+ 'members' => ['foo'],
+ 'mongo' => 'id',
+ 'nickname' => 'nickname',
+ 'notify' => true,
+ 'path' => '/a/path',
+ 'passthru_level' => 'DEBUG',
+ 'persistent' => true,
+ 'port' => 514,
+ 'publisher' => 'id',
+ 'redis' => ['id' => 'id'],
+ 'release' => '1.0.1',
+ 'region' => 'eu',
+ 'room' => 'room_id',
+ 'source' => 'source_id',
+ 'stop_buffering' => false,
+ 'store' => '/',
+ 'subject' => 'subject',
+ 'tags' => ['a_tag'],
+ 'team' => 'team',
+ 'time' => 3600,
+ 'timeout' => 1.2,
+ 'title' => 'title',
+ 'token' => 'api_token',
+ 'to_email' => 'toemail@test.com',
+ 'url' => 'http://localhost',
+ 'user' => 'user_id',
+ 'use_attachment' => false,
+ 'use_locking' => true,
+ 'use_short_attachment' => true,
+ 'use_ssl' => false,
+ 'verbosity_levels' => ['DEBUG'],
+ 'webhook_url' => 'http://localhost',
+ ];
+ }
+
+ /**
+ * @dataProvider provideHandlersInvalidConfigurations
+ * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
+ */
+ public function testHandlerInvalidConfiguration($config)
+ {
+ $this->process([$config]);
+ }
+
+ public function provideHandlersInvalidConfigurations()
+ {
+ $madatoryParams = [
+ 'stream' => ['path'],
+ 'gelf' => ['publisher'],
+ 'rotating_file' => ['path'],
+ 'mongo' => ['id', 'host', 'pass'],
+ 'elasticsearch' => ['elasticsearch'],
+ 'redis' => ['redis'],
+ 'predis' => ['redis'],
+ 'fingers_crossed' => ['handler'],
+ 'filter' => ['handler'],
+ 'buffer' => ['handler'],
+ 'deduplication' => ['handler'],
+ 'group' => ['members'],
+ 'whatfailuregroup' => ['members'],
+ 'syslog' => ['ident'],
+ 'syslogudp' => ['host'],
+ 'swift_mailer' => ['from_email', 'to_email', 'subject'],
+ 'native_mailer' => ['from_email', 'to_email', 'subject'],
+ 'socket' => ['connection_string'],
+ 'pushover' => ['token', 'user'],
+ 'raven' => ['dsn', 'client_id'],
+ 'sentry' => ['dsn', 'client_id'],
+ 'hipchat' => ['token', 'room'],
+ 'slack' => ['token', 'channel'],
+ 'slackwebhook' => ['webhook_url', 'channel'],
+ 'slackbot' => ['team', 'token', 'channel'],
+ 'cube' => ['url'],
+ 'amqp' => ['exchange'],
+ 'loggly' => ['token'],
+ 'logentries' => ['token'],
+ 'insightops' => ['token', 'region'],
+ 'flowdock' => ['token', 'source', 'from_email'],
+ 'rollbar' => ['id', 'token'],
+ 'server_log' => ['host'],
+ ];
+
+ $handlersConfigurations = $this->getHandlersConfigurations();
+ $handlersConfigurationParams = $this->provideAllHandlersConfigurationParams();
+
+ $configs = [];
+
+ foreach ($handlersConfigurations as $handlerType => $handler) {
+ $mandatoryParams = array_key_exists($handlerType, $madatoryParams) ? $madatoryParams[$handlerType] : [];
+ $invalidParams = array_diff_key($handlersConfigurationParams, $handler);
+ $handlerMandatoryParams = array_intersect_key($handlersConfigurationParams, array_flip($mandatoryParams));
+ foreach($invalidParams as $invalidParamKey => $invalidParamValue) {
+ $configs[] = [
+ [
+ 'handlers' => [
+ $handlerType => array_merge([
+ 'type' => $handler['type'],
+ $invalidParamKey => $invalidParamValue
+ ], $handlerMandatoryParams)
+ ]
+ ]
+ ];
+ }
+ }
+
+ return $configs;
+ }
+
+// /**
+// * @dataProvider provideFingersCrossedHandlerConfigurationInvalidParams
+// * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
+// */
+// public function testFingersCrossedHandlerInvalidConfiguration($param, $value)
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(['type' => 'fingers_crossed'], ['handler' => 'handler_name', $param => $value]),
+// ]
+// ],
+// ];
+//
+// $this->process($configs);
+// }
+//
+// public function provideFingersCrossedHandlerConfigurationInvalidParams()
+// {
+// return array_diff_key(
+// $this->provideAllHandlersConfigurationParams(),
+// $this->provideFingersCrossedHandlerValidConfigurationParams()
+// );
+// }
+//
+// private function provideFingersCrossedHandlerValidConfigurationParams()
+// {
+// return [
+// 'handler' => 'handler_name',
+// 'action_level' => 'DEBUG',
+// 'activation_strategy' => 'DEBUG',
+// 'excluded_404s' => ['^/.*'],
+// 'excluded_http_codes' => [404],
+// 'buffer_size' => 0,
+// 'stop_buffering' => false,
+// 'passthru_level' => 'DEBUG',
+// 'bubble' => false,
+// ];
+// }
+//
+// public function testFingersCrossedHandlerWithActionLevelExcluded404sConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(
+// ['type' => 'fingers_crossed'],
+// [
+// 'handler' => 'handler_name',
+// 'action_level' => 'DEBUG',
+// 'excluded_http_codes' => [404],
+// 'buffer_size' => 0,
+// 'stop_buffering' => false,
+// 'passthru_level' => 'DEBUG',
+// 'bubble' => false,
+// ]
+// ),
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
+//
+// public function testFingersCrossedHandlerWithActionLevelExcludedHttpCodesConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(
+// ['type' => 'fingers_crossed'],
+// [
+// 'handler' => 'handler_name',
+// 'action_level' => 'DEBUG',
+// 'excluded_404s' => ['^/.*'],
+// 'buffer_size' => 0,
+// 'stop_buffering' => false,
+// 'passthru_level' => 'DEBUG',
+// 'bubble' => false,
+// ]
+// ),
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
+//
+// public function testFingersCrossedHandlerWithActivationStrategyConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(
+// ['type' => 'fingers_crossed'],
+// [
+// 'handler' => 'handler_name',
+// 'activation_strategy' => 'DEBUG',
+// 'buffer_size' => 0,
+// 'stop_buffering' => false,
+// 'passthru_level' => 'DEBUG',
+// 'bubble' => false,
+// ]
+// ),
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
+//
+// /**
+// * @dataProvider provideFilterHandlerConfigurationInvalidParams
+// * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
+// */
+// public function testFilterHandlerInvalidConfiguration($param, $value)
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(['type' => 'filter'], ['handler' => 'handler_name', $param => $value]),
+// ]
+// ],
+// ];
+//
+// $this->process($configs);
+// }
+//
+// public function provideFilterHandlerConfigurationInvalidParams()
+// {
+// return array_diff_key(
+// $this->provideAllHandlersConfigurationParams(),
+// $this->provideFilterHandlerValidConfigurationParams()
+// );
+// }
+//
+// private function provideFilterHandlerValidConfigurationParams()
+// {
+// return [
+// 'handler' => 'handler_name',
+// 'accepted_levels' => ['DEBUG'],
+// 'min_level' => 'DEBUG',
+// 'max_level' => 'DEBUG',
+// 'bubble' => false,
+// ];
+// }
+//
+// public function testFilterHandlerWithAcceptedLevelsValidConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(['type' => 'filter'], [
+// 'handler' => 'handler_name',
+// 'accepted_levels' => ['DEBUG'],
+// 'bubble' => false,
+// ]),
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
+//
+// public function testFilterHandlerWithMinMaxLevelsValidConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(['type' => 'filter'], [
+// 'handler' => 'handler_name',
+// 'min_level' => 'DEBUG',
+// 'max_level' => 'DEBUG',
+// 'bubble' => false,
+// ]),
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
+//
+// /**
+// * @dataProvider provideRollbarHandlerConfigurationInvalidParams
+// * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
+// */
+// public function testRollbarHandlerInvalidConfiguration($param, $value)
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(['type' => 'rollbar'], ['id' => 'id', 'token' => 'api_token', $param => $value]),
+// ]
+// ],
+// ];
+//
+// $this->process($configs);
+// }
+//
+// public function provideRollbarHandlerConfigurationInvalidParams()
+// {
+// return array_diff_key(
+// $this->provideAllHandlersConfigurationParams(),
+// $this->provideRollbarHandlerValidConfigurationParams()
+// );
+// }
+//
+// private function provideRollbarHandlerValidConfigurationParams()
+// {
+// return [
+// 'id' => 'id',
+// 'token' => 'api_token',
+// 'config' => ['config' => 'config'],
+// 'level' => 'DEBUG',
+// 'bubble' => false,
+// ];
+// }
+//
+// public function testRollbarHandlerValidIdConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(
+// ['type' => 'rollbar'],
+// [
+// 'id' => 'id',
+// 'config' => ['config' => 'config'],
+// 'level' => 'DEBUG',
+// 'bubble' => false,
+// ]
+// )
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
+//
+// public function testRollbarHandlerValidTokenConfiguration()
+// {
+// $configs = [
+// [
+// 'handlers' => [
+// 'foo' => array_merge(
+// ['type' => 'rollbar'],
+// [
+// 'token' => 'api_token',
+// 'config' => ['config' => 'config'],
+// 'level' => 'DEBUG',
+// 'bubble' => false,
+// ]
+// )
+// ]
+// ],
+// ];
+//
+// $config = $this->process($configs);
+//
+// $this->assertArrayHasKey('handlers', $config);
+// }
}
diff --git a/Tests/DependencyInjection/Fixtures/xml/handlers_with_channels.xml b/Tests/DependencyInjection/Fixtures/xml/handlers_with_channels.xml
index 363f8a7e..5b9aabb5 100644
--- a/Tests/DependencyInjection/Fixtures/xml/handlers_with_channels.xml
+++ b/Tests/DependencyInjection/Fixtures/xml/handlers_with_channels.xml
@@ -30,7 +30,7 @@
foo
-
+
nested
!foo