Closed tourze closed 1 year ago
/cc @MatTheCat maybe?
Yes I remember it was to avoid memory leaks: https://github.com/symfony/symfony/pull/30339
this is because in a non-swoole setup, the profiler does not collect anything in the CLI (as web requests are not handled there) so this avoids memory leaks for long-running commands.
We would need a way to disable that SAPI check for swoole.
How about make a patch like:
public static function configureLogger(mixed $logger)
{
- if (\is_object($logger) && method_exists($logger, 'removeDebugLogger') && \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
+ if (\is_object($logger) && method_exists($logger, 'removeDebugLogger') && $_ENV['APP_ENV'] === 'prod') {
$logger->removeDebugLogger();
}
}
I patch it locally, and works fine now ( in dev and test environment).
Your proposal has two issues:
I don't know much about Swoole, but could you try checking Swoole\Coroutine::getCid()
(from https://github.com/swoole/swoole-src/issues/4284#issuecomment-871283010)?
After some testing we could indeed check if Swoole\Coroutine
exists and its getCid
method returns -1
.
But seeing that Roadrunner also leverages the cli SAPI makes me wonder if it really is Symfony’s responsibility to determine whether collecting logs or not :thinking:
Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?
Hello? This issue is about to be closed if nobody replies.
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!
Symfony version(s) affected
6.1.*
Description
I start to develop a new project using symfony and swoole. Symfony & Swoole is really fast, but when running in APP_ENV=dev environment, I cannnot see any log in profiler bar. After some reseach, I found that the problem is \Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass.
This classs will remove all debug logger when symfony is under CLI. So swoole or any other same framework like workerman/reactphp is not working well.
How to reproduce
Possible Solution
I dont know if we can detect the running environment while kernel compile. Maybe we can add a new env variable, just like $_ENV['REMOTE_DEBUG_LOGGER'] (default: false) to replace the check in \Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass::configureLogger.
Additional Context
No response