Skip to content

Commit 95cf142

Browse files
committed
Merge pull request #153 from nicolas-grekas/include-stack
Add include_stacktraces configuration option to handlers
2 parents 08ac861 + 8cdd4a1 commit 95cf142

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public function getConfigTreeBuilder()
292292
->scalarNode('priority')->defaultValue(0)->end()
293293
->scalarNode('level')->defaultValue('DEBUG')->end()
294294
->booleanNode('bubble')->defaultTrue()->end()
295+
->booleanNode('include_stacktraces')->defaultFalse()->end()
295296
->scalarNode('path')->defaultValue('%kernel.logs_dir%/%kernel.environment%.log')->end() // stream and rotating
296297
->scalarNode('file_permission') // stream and rotating
297298
->defaultNull()

DependencyInjection/MonologExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
130130
$definition = new Definition(sprintf('%%monolog.handler.%s.class%%', $handler['type']));
131131
$handler['level'] = $this->levelToMonologConst($handler['level']);
132132

133+
if ($handler['include_stacktraces']) {
134+
$definition->setConfigurator(array('Symfony\\Bundle\\MonologBundle\\MonologBundle', 'includeStacktraces'));
135+
}
136+
133137
switch ($handler['type']) {
134138
case 'service':
135139
$container->setAlias($handlerId, $handler['id']);

MonologBundle.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Bundle\MonologBundle;
1313

14+
use Monolog\Formatter\LineFormatter;
15+
use Monolog\Handler\HandlerInterface;
1416
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\AddSwiftMailerTransportPass;
1517
use Symfony\Component\HttpKernel\Bundle\Bundle;
1618
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -34,4 +36,15 @@ public function build(ContainerBuilder $container)
3436
$container->addCompilerPass(new AddProcessorsPass());
3537
$container->addCompilerPass(new AddSwiftMailerTransportPass());
3638
}
39+
40+
/**
41+
* @internal
42+
*/
43+
public static function includeStacktraces(HandlerInterface $handler)
44+
{
45+
$formatter = $handler->getFormatter();
46+
if ($formatter instanceof LineFormatter) {
47+
$formatter->includeStacktraces();
48+
}
49+
}
3750
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/dependency-injection": "~2.3|~3.0",
2222
"symfony/config": "~2.3|~3.0",
2323
"symfony/http-kernel": "~2.3|~3.0",
24-
"monolog/monolog": "~1.8"
24+
"monolog/monolog": "~1.12"
2525
},
2626
"require-dev": {
2727
"symfony/yaml": "~2.3|~3.0",

0 commit comments

Comments
 (0)