Skip to content

Commit 98ed852

Browse files
committed
[Monolog] Disable DebugLogger in CLI
1 parent fec0475 commit 98ed852

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ public function reset()
7575
$this->clear();
7676
}
7777

78+
public function removeDebugLogger()
79+
{
80+
foreach ($this->processors as $k => $processor) {
81+
if ($processor instanceof DebugLoggerInterface) {
82+
unset($this->processors[$k]);
83+
}
84+
}
85+
86+
foreach ($this->handlers as $k => $handler) {
87+
if ($handler instanceof DebugLoggerInterface) {
88+
unset($this->handlers[$k]);
89+
}
90+
}
91+
}
92+
7893
/**
7994
* Returns a DebugLoggerInterface instance if one is registered with this logger.
8095
*

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ public function process(ContainerBuilder $container)
3030
}
3131

3232
$definition = $container->getDefinition('monolog.logger_prototype');
33+
$definition->setConfigurator([__CLASS__, 'configureLogger']);
3334
$definition->addMethodCall('pushProcessor', [new Reference('debug.log_processor')]);
3435
}
36+
37+
public function configureLogger($logger)
38+
{
39+
if (method_exists($logger, 'removeDebugLogger') && 'cli' === \PHP_SAPI) {
40+
$logger->removeDebugLogger();
41+
}
42+
}
3543
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy