8000 MonologBundle by Seldaek · Pull Request #111 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

MonologBundle #111

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

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactored the configuration class to be DRY
  • Loading branch information
stof committed Feb 25, 2011
commit bd0f0052d61005de8f2a0449ee60a237b6490686
Original file line number Diff line number Diff line change
Expand Up @@ -34,55 +34,52 @@ public function getConfigTree()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('monolog', 'array');

$rootNode
$handlersPrototype = $rootNode
->fixXmlConfig('handler')
->arrayNode('handlers')
->canBeUnset()
->performNoDeepMerging()
->useAttributeAsKey('name')
->prototype('array')
->performNoDeepMerging()
->scalarNode('type')
->isRequired()
->beforeNormalization()
->always()
->then(function($v) { return strtolower($v); })
->end()
->end()
->scalarNode('level')->defaultValue('INFO')->end()
->booleanNode('bubble')->defaultFalse()->end()
->scalarNode('path')->end() // stream specific
->scalarNode('action_level')->end() // fingerscrossed specific
->scalarNode('buffer_size')->end() // fingerscrossed specific
->arrayNode('handler')
->performNoDeepMerging()
->scalarNode('type')
->isRequired()
->beforeNormalization()
->always()
->then(function($v) { return strtolower($v); })
->end()
->end()
->scalarNode('level')->defaultValue('DEBUG')->end()
->booleanNode('bubble')->defaultFalse()->end()
->scalarNode('path')->end() // stream specific
->validate()
->ifTrue(function($v) { return 'stream' === $v['type'] && !isset($v['path']); })
->thenInvalid('The path has to be specified to use a StreamHandler')
->end()
->end()
->builder($this->getHandlerSubnode())
->validate()
->ifTrue(function($v) { return 'fingerscrossed' === $v['type'] && !isset($v['handler']); })
->thenInvalid('The handler has to be specified to use a FingersCrossedHandler')
->end()
->validate()
->ifTrue(function($v) { return 'stream' === $v['type'] && !isset($v['path']); })
->thenInvalid('The path has to be specified to use a StreamHandler')
->end()
;
$this->addHandlerSection($handlersPrototype);

return $treeBuilder->buildTree();
}

private function addHandlerSection(NodeBuilder $node)
{
$node
->performNoDeepMerging()
->scalarNode('type')
->isRequired()
->beforeNormalization()
->always()
->then(function($v) { return strtolower($v); })
->end()
->end()
->scalarNode('level')->defaultValue('DEBUG')->end()
->booleanNode('bubble')->defaultFalse()->end()
->scalarNode('path')->end() // stream specific
->validate()
->ifTrue(function($v) { return 'stream' === $v['type'] && !isset($v['path']); })
->thenInvalid('The path has to be specified to use a StreamHandler')
->end()
;
}

return $treeBuilder->buildTree();
private function getHandlerSubnode()
{
$node = new NodeBuilder('handler', 'array');
420E $this->addHandlerSection($node);

return $node;
}
}
0