From 17533da49ce7113ca5401fd1dc1705ddef15b58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 22 Feb 2019 11:16:14 +0100 Subject: [PATCH] [Monolog] Disable DebugLogger in CLI --- src/Symfony/Bridge/Monolog/Logger.php | 15 +++++++++++++++ .../Compiler/AddDebugLogProcessorPass.php | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Symfony/Bridge/Monolog/Logger.php b/src/Symfony/Bridge/Monolog/Logger.php index de021426e03b9..ee4ffd243c644 100644 --- a/src/Symfony/Bridge/Monolog/Logger.php +++ b/src/Symfony/Bridge/Monolog/Logger.php @@ -75,6 +75,21 @@ public function reset() $this->clear(); } + public function removeDebugLogger() + { + foreach ($this->processors as $k => $processor) { + if ($processor instanceof DebugLoggerInterface) { + unset($this->processors[$k]); + } + } + + foreach ($this->handlers as $k => $handler) { + if ($handler instanceof DebugLoggerInterface) { + unset($this->handlers[$k]); + } + } + } + /** * Returns a DebugLoggerInterface instance if one is registered with this logger. * diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php index b4da145010403..dbe88b064bddd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php @@ -30,6 +30,14 @@ public function process(ContainerBuilder $container) } $definition = $container->getDefinition('monolog.logger_prototype'); + $definition->setConfigurator([__CLASS__, 'configureLogger']); $definition->addMethodCall('pushProcessor', [new Reference('debug.log_processor')]); } + + public static function configureLogger($logger) + { + if (method_exists($logger, 'removeDebugLogger') && \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { + $logger->removeDebugLogger(); + } + } } 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