-
-
Notifications
You must be signed in to change notification settings - Fork 240
Ensure all handlers are explicitly closed on kernel shutdown #377
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
base: 4.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||
| <?php | ||||||
|
|
||||||
|
|
||||||
| namespace Symfony\Bundle\MonologBundle; | ||||||
|
|
||||||
|
|
||||||
| use Monolog\Handler\HandlerInterface; | ||||||
|
|
||||||
| class HandlerLifecycleManager | ||||||
| { | ||||||
| /** | ||||||
| * @var HandlerInterface[] | ||||||
| */ | ||||||
| private $handlers; | ||||||
|
|
||||||
| public function __construct(\IteratorAggregate $handlers) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The type
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the bundle supports PHP 5.6+ currently
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should drop support for SF 3.X, and bump PHP to 7.1 |
||||||
| { | ||||||
| $this->handlers = $handlers; | ||||||
| } | ||||||
|
|
||||||
| public function close() | ||||||
| { | ||||||
| foreach ($this->handlers as $handler) { | ||||||
| $handler->close(); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will instantiate all the handlers, even those that have not been used. |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,4 +52,14 @@ public static function includeStacktraces(HandlerInterface $handler) | |||||||||
| $formatter->includeStacktraces(); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public function shutdown() | ||||||||||
| { | ||||||||||
| parent::shutdown(); | ||||||||||
|
|
||||||||||
| $handlerManager = $this->container->get('monolog.handler_manager'); | ||||||||||
|
|
||||||||||
| $handlerManager->close(); | ||||||||||
|
Comment on lines
+60
to
+62
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,5 +40,9 @@ | |
| <service id="monolog.http_client" class="Symfony\Contracts\HttpClient\HttpClientInterface" public="false"> | ||
| <factory class="Symfony\Component\HttpClient\HttpClient" method="create" /> | ||
| </service> | ||
|
|
||
| <service id="monolog.handler_manager" class="Symfony\Bundle\MonologBundle\HandlerLifecycleManager" public="true"> | ||
| <argument type="tagged_iterator" tag="monolog.handler" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I'm familiar enough with the Container to change this right now but given #377 (comment) I should probably pause on this PR now anyway? |
||
| </service> | ||
| </services> | ||
| </container> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be tagged as
@internal. We really don't want to expose it in the BC promise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.