Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf3943a9

Browse files
[Debug] make screaming configurable
1 parenta8888be commitf3943a9

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ public function load(array $configs, ContainerBuilder $container)
127127
$definition =$container->findDefinition('debug.debug_handlers_listener');
128128

129129
if ($container->hasParameter('templating.helper.code.file_link_format')) {
130-
$definition->replaceArgument(4,'%templating.helper.code.file_link_format%');
130+
$definition->replaceArgument(5,'%templating.helper.code.file_link_format%');
131131
}
132132

133133
if ($container->getParameter('kernel.debug')) {
134134
$loader->load('debug.xml');
135135

136136
$definition->replaceArgument(0,array(newReference('http_kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE),'terminateWithException'));
137+
$definition->replaceArgument(3,E_ALL |E_STRICT);
137138

138139
$definition =$container->findDefinition('http_kernel');
139140
$definition->replaceArgument(2,newReference('debug.controller_resolver'));

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<argument /><!-- Exception handler-->
1717
<argumenttype="service"id="logger"on-invalid="null" />
1818
<argument /><!-- Log levels map for enabled error levels-->
19-
<argument>%kernel.debug%</argument>
19+
<argument>null</argument>
20+
<argument>true</argument>
2021
<argument>null</argument><!-- %templating.helper.code.file_link_format%-->
2122
</service>
2223

‎src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php‎

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,52 @@ class DebugHandlersListener implements EventSubscriberInterface
2727
private$exceptionHandler;
2828
private$logger;
2929
private$levels;
30-
private$debug;
30+
private$throwAt;
31+
private$scream;
32+
private$fileLinkFormat;
3133

3234
/**
33-
* @param callable $exceptionHandler A handler that will be called on Exception
35+
* @param callable|null $exceptionHandler A handler that will be called on Exception
3436
* @param LoggerInterface|null $logger A PSR-3 logger
3537
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
36-
* @param bool $debug Enables/disables debug mode
38+
* @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value
39+
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
3740
* @param string $fileLinkFormat The format for links to source files
3841
*/
39-
publicfunction__construct($exceptionHandler,LoggerInterface$logger =null,$levels =null,$debug =true,$fileLinkFormat =null)
42+
publicfunction__construct($exceptionHandler,LoggerInterface$logger =null,$levels =null,$throwAt = -1,$scream =true,$fileLinkFormat =null)
4043
{
4144
$this->exceptionHandler =$exceptionHandler;
4245
$this->logger =$logger;
4346
$this->levels =$levels;
44-
$this->debug =$debug;
47+
$this->throwAt =is_numeric($throwAt) ? (int)$throwAt : (null ===$throwAt ?null : ($throwAt ? -1 :null));
48+
$this->scream = (bool)$scream;
4549
$this->fileLinkFormat =$fileLinkFormat ?:ini_get('xdebug.file_link_format') ?:get_cfg_var('xdebug.file_link_format');
4650
}
4751

4852
publicfunctionconfigure()
4953
{
50-
if ($this->logger) {
51-
$handler =set_error_handler('var_dump',0);
52-
$handler =is_array($handler) ?$handler[0] :null;
53-
restore_error_handler();
54-
if ($handlerinstanceof ErrorHandler) {
55-
if ($this->debug) {
56-
$handler->throwAt(-1);
57-
}
54+
$handler =set_error_handler('var_dump',0);
55+
$handler =is_array($handler) ?$handler[0] :null;
56+
restore_error_handler();
57+
if ($handlerinstanceof ErrorHandler) {
58+
if ($this->logger) {
5859
$handler->setDefaultLogger($this->logger,$this->levels);
5960
if (is_array($this->levels)) {
6061
$scream =0;
6162
foreach ($this->levelsas$type =>$log) {
6263
$scream |=$type;
6364
}
64-
$this->levels =$scream;
65+
}else {
66+
$scream =null ===$this->levels ?E_ALL |E_STRICT :$this->levels;
6567
}
66-
$handler->screamAt($this->levels);
68+
if ($this->scream) {
69+
$handler->screamAt($scream);
70+
}
71+
$this->logger =$this->levels =null;
72+
}
73+
if (null !==$this->throwAt) {
74+
$handler->throwAt($this->throwAt,true);
6775
}
68-
$this->logger =$this->levels =null;
6976
}
7077
if ($this->exceptionHandler) {
7178
$handler =set_exception_handler('var_dump');
@@ -78,7 +85,9 @@ public function configure()
7885
}
7986
if ($handlerinstanceof ExceptionHandler) {
8087
$handler->setHandler($this->exceptionHandler);
81-
$handler->setFileLinkFormat($this->fileLinkFormat);
88+
if (null !==$this->fileLinkFormat) {
89+
$handler->setFileLinkFormat($this->fileLinkFormat);
90+
}
8291
}
8392
$this->exceptionHandler =null;
8493
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp