Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MonologBridge] DebugHandler buffers ad nauseum #25876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolas-grekas opened this issue Jan 21, 2018 · 3 comments
Closed

[MonologBridge] DebugHandler buffers ad nauseum #25876

nicolas-grekas opened this issue Jan 21, 2018 · 3 comments

Comments

@nicolas-grekas
Copy link
Member

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.7

Up to OOM, problematic on the CLI especially.
See #21061 and symfony/monolog-bundle#165

@ostrolucky
Copy link
Contributor

I'm interested in fixing this issue. My idea is to start to write into tmpfile() instead of memory in non-blocking mode after certain static limit, e.g. 10000 records. getLogs() method would then return concatenated records in array and in file.

@linaori
Copy link
Contributor

linaori commented Jun 13, 2018

Ran into this issue as well, doesn't seem to be a clean way to disable this.

@fabpot fabpot closed this as completed Mar 17, 2019
fabpot added a commit that referenced this issue Mar 17, 2019
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Monolog] Disable DebugLogger in CLI

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   |
| Fixed tickets | #30333 symfony/monolog-bundle#165 #25876
| License       | MIT
| Doc PR        |

<details>
<summary>Considering this code:</summary>

```php
namespace App\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class LeakCommand extends Command
{
    protected static $defaultName = 'leak';

    private $logger;

    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;

        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $reportedAt = time();
        while (true) {
            $this->logger->info('Hello');

            if (time() - $reportedAt >= 1) {
                $output->writeln(sprintf('%dMb', memory_get_usage() / 1024 / 1024));
                $reportedAt = time();
            }
        }
    }
}
```

</details>

Without the patch
```
>…/dev/labs/symfony/website-skeleton(monolog %) bin/console leak
7Mb
28Mb
51Mb
76Mb
97Mb
````

With the patch
```
>…/dev/labs/symfony/website-skeleton(monolog %) bin/console leak
6Mb
6Mb
6Mb
6Mb
```

Commits
-------

17533da [Monolog] Disable DebugLogger in CLI
@alex-pravdin-sn
Copy link

How to disable this feature? I need to collect all logs in unit tests which obviously runs in CLI mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants