Skip to content

Commit 46773f1

Browse files
committed
Fix memory leak usage
1 parent a65589e commit 46773f1

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

Plugin/MonologPlugin.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414

1515
class MonologPlugin
1616
{
17-
public function aroundSetHandlers(Monolog $subject, callable $proceed, array $handlers): void
17+
public function beforeSetHandlers(Monolog $subject, array $handlers): array
1818
{
1919
$magentoHandlers = [];
20-
foreach ($handlers as $handler) {
20+
foreach ($handlers as $key => $handler) {
2121
if ($handler instanceof MagentoHandlerInterface && $handler->isEnabled()) {
22-
$magentoHandlers[] = $handler->getInstance();
22+
$magentoHandlers[$key] = $handler->getInstance();
2323
} elseif ($handler instanceof HandlerInterface) {
24-
$magentoHandlers[] = $handler;
24+
$magentoHandlers[$key] = $handler;
2525
}
2626
}
2727

28-
$proceed($magentoHandlers);
28+
return [$magentoHandlers];
2929
}
3030
}

etc/di.xml

+6-12
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,26 @@
55
* See LICENSE bundled with this library for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
109

11-
<virtualType name="gelfTransport" type="Opengento\Logger\Transport\UdpTransportWrapper">
10+
<virtualType name="GelfTransport" type="Opengento\Logger\Transport\UdpTransportWrapper">
1211
<arguments>
1312
<argument name="hostPath" xsi:type="string">loggin/gelf/transport_host</argument>
1413
<argument name="portPath" xsi:type="string">loggin/gelf/transport_port</argument>
1514
</arguments>
1615
</virtualType>
1716

18-
<virtualType name="gelfPublisher" type="Gelf\Publisher">
17+
<virtualType name="GelfPublisher" type="Gelf\Publisher">
1918
<arguments>
20-
<argument name="transport" xsi:type="object">gelfTransport</argument>
19+
<argument name="transport" xsi:type="object">GelfTransport</argument>
2120
</arguments>
2221
</virtualType>
2322

2423
<virtualType name="GelfHandler" type="Opengento\Logger\Handler\GelfHandler">
2524
<arguments>
2625
<argument name="isEnabled" xsi:type="string">loggin/gelf/is_enabled</argument>
2726
<argument name="levelPath" xsi:type="string">loggin/gelf/level</argument>
28-
<argument name="publisher" xsi:type="object">gelfPublisher</argument>
27+
<argument name="publisher" xsi:type="object">GelfPublisher</argument>
2928
</arguments>
3029
</virtualType>
3130

@@ -73,13 +72,8 @@
7372

7473
<virtualType name="NoopHandler" type="Monolog\Handler\NullHandler"/>
7574

76-
<type name="Magento\Framework\Logger\Monolog">
77-
<plugin name="override_set_handlers_method" type="Opengento\Logger\Plugin\MonologPlugin" sortOrder="1"/>
78-
</type>
79-
8075
<type name="Magento\Framework\Logger\Monolog">
8176
<arguments>
82-
<argument name="name" xsi:type="string">main</argument>
8377
<argument name="handlers" xsi:type="array">
8478
<item name="gelf" xsi:type="object">GelfHandler</item>
8579
<item name="mail" xsi:type="object">MailHandler</item>
@@ -93,6 +87,6 @@
9387
<item name="custom_context" xsi:type="object">Opengento\Logger\Processor\CustomContextProcessor</item>
9488
</argument>
9589
</arguments>
90+
<plugin name="override_set_handlers_method" type="Opengento\Logger\Plugin\MonologPlugin" sortOrder="1"/>
9691
</type>
9792
</config>
98-

0 commit comments

Comments
 (0)