-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Monolog] Really reset logger when calling logger::reset() #30410
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
Conversation
lyrixx
commented
Feb 28, 2019
•
edited
Loading
edited
Q | A |
---|---|
Branch? | 4.2 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | |
License | MIT |
Doc PR |
looks like Fabbot is broken. Anyway, this patch is much better, because it actually does the work. BTW, introducing the method But it is still not perfect. ATM we rely on the fact that processors and handlers are shared among all loggers. But there is one logger per channel. So when we call Let me explain this a bit more. Let's consider this config: monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: buffer
buffer_size: 50
channels: ["!php"]
buffer:
type: buffer
handler: file
file:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%.log'
php:
type: fingers_crossed
action_level: error
handler: php_file
buffer_size: 50
channels: ["php"]
php_file:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%-php.log' And with this PHP script: <?php
require __DIR__.'/vendor/autoload.php';
$k = new AppKernel('dev', true);
$k->boot();
$c = $k->getContainer();
// (I had to patch SF to make theses services public)
$c->get('monolog.logger.php')->debug('debug from php - XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
$c->get('monolog.logger.consumer')->debug('debug from consumer - YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY');
$c->get('monolog.logger.consumer')->reset();
dump([
'logger php' => $c->get('monolog.logger.php'),
'logger consumer' => $c->get('monolog.logger.consumer')
]); We can simulate our issue. In my consumer, I got In my application, I don't have this issue because our configuration is more classical. But I know some people are doing this kind of configuration. We need to know that :) |
Isn't it something we can do on 3.4? |
Thank you @lyrixx. |
… (lyrixx) This PR was merged into the 4.2 branch. Discussion ---------- [Monolog] Really reset logger when calling logger::reset() | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 08a20ee [Monolog] Really reset logger when calling logger::reset()