8000 [RFC][Monolog] Consider adding a hard limit on log buffered in dev · Issue #30333 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC][Monolog] Consider adding a hard limit on log buffered in dev #30333

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
lyrixx opened this issue Feb 21, 2019 · 4 comments
Closed

[RFC][Monolog] Consider adding a hard limit on log buffered in dev #30333

lyrixx opened this issue Feb 21, 2019 · 4 comments
Labels
MonologBridge RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@lyrixx
Copy link
Member
lyrixx commented Feb 21, 2019

Description

When running consumer / worker in dev env, they leaks a lot. Symfony buffer all logs (mainly for the profiler). In CLI I'm not sure it makes sens.

So IMHO we could disable this feature in CLI or at least add an hard limit.

WDYT ?

@lyrixx lyrixx added RFC RFC = Request For Comments (proposals about features that you want to be discussed) MonologBridge labels Feb 21, 2019
@linaori
Copy link
Contributor
linaori commented Feb 22, 2019

Instead of not logging, what if we add a feature to limit messages in memory and force a flush after X messages and reset the counter?

EDIT: Might cause problems with fingers crossed though

@lyrixx
Copy link
Member Author
lyrixx commented Feb 22, 2019

@linaori I'm sorry if I was not clear enough, but I'm not talking of not logging, but instead I would like to disable the buffering.

Anyway, I will have a look at this this morning

@linaori
Copy link
Contributor
linaori commented Feb 22, 2019

My bad on that part! The buffering for fingers crossed still stands though, but perhaps we should make a file system buffer or make it possible to clear this particular buffer per worker iteration? Perhaps using kernel.reset to clear this?

@lyrixx
Copy link
Member Author
lyrixx commented Feb 22, 2019

actually I have no issue with finger crossed since it is not enabled in dev by default :)

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MonologBridge RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

3 participants
0