|
55 | 55 | * - [level]: level name or int value, defaults to DEBUG |
56 | 56 | * - [bubble]: bool, defaults to true |
57 | 57 | * |
| 58 | + * - mongo: |
| 59 | + * - mongo: |
| 60 | + * - id: optional if host is given |
| 61 | + * - host: database host name, optional if id is given |
| 62 | + * - [port]: defaults to 27017 |
| 63 | + * - [user]: database user name |
| 64 | + * - pass: mandatory only if user is present |
| 65 | + * - [database]: defaults to monolog |
| 66 | + * - [collection]: defaults to logs |
| 67 | + * - [level]: level name or int value, defaults to DEBUG |
| 68 | + * - [bubble]: bool, defaults to true |
| 69 | + * |
58 | 70 | * - fingers_crossed: |
59 | 71 | * - handler: the wrapped handler's name |
60 | 72 | * - [action_level|activation_strategy]: minimum level or service id to activate the handler, defaults to WARNING |
@@ -247,6 +259,34 @@ public function getConfigTreeBuilder() |
247 | 259 | ->thenInvalid('What must be set is either the hostname or the id.') |
248 | 260 | ->end() |
249 | 261 | ->end() // gelf |
| 262 | + ->arrayNode('mongo') |
| 263 | + ->canBeUnset() |
| 264 | + ->beforeNormalization() |
| 265 | + ->ifString() |
| 266 | + ->then(function($v) { return array('id'=> $v); }) |
| 267 | + ->end() |
| 268 | + ->children() |
| 269 | + ->scalarNode('id')->end() |
| 270 | + ->scalarNode('host')->end() |
| 271 | + ->scalarNode('port')->defaultValue(27017)->end() |
| 272 | + ->scalarNode('user')->end() |
| 273 | + ->scalarNode('pass')->end() |
| 274 | + ->scalarNode('database')->defaultValue('monolog')->end() |
| 275 | + ->scalarNode('collection')->defaultValue('logs')->end() |
| 276 | + ->end() |
| 277 | + ->validate() |
| 278 | + ->ifTrue(function($v) { |
| 279 | + return !isset($v['id']) && !isset($v['host']); |
| 280 | + }) |
| 281 | + ->thenInvalid('What must be set is either the host or the id.') |
| 282 | + ->end() |
| 283 | + ->validate() |
| 284 | + ->ifTrue(function($v) { |
| 285 | + return isset($v['user']) && !isset($v['pass']); |
| 286 | + }) |
| 287 | + ->thenInvalid('If you set user, you must provide a password.') |
| 288 | + ->end() |
| 289 | + ->end() // mongo |
250 | 290 | ->arrayNode('members') // group |
251 | 291 | ->canBeUnset() |
252 | 292 | ->performNoDeepMerging() |
@@ -440,6 +480,10 @@ public function getConfigTreeBuilder() |
440 | 480 | ->ifTrue(function($v) { return 'cube' === $v['type'] && empty($v['url']); }) |
441 | 481 | ->thenInvalid('The url has to be specified to use a CubeHandler') |
442 | 482 | ->end() |
| 483 | + ->validate() |
| 484 | + ->ifTrue(function($v) { return 'mongo' === $v['type'] && !isset($v['mongo']); }) |
| 485 | + ->thenInvalid('The mongo configuration has to be specified to use a MongoHandler') |
| 486 | + ->end() |
443 | 487 | ->validate() |
444 | 488 | ->ifTrue(function($v) { return 'amqp' === $v['type'] && empty($v['exchange']); }) |
445 | 489 | ->thenInvalid('The exchange has to be specified to use a AmqpHandler') |
|
0 commit comments