conekta / customer-magento-plugin

5 stars 9 forks source link

Logger is broken #47

Closed MagicLegend closed 1 year ago

MagicLegend commented 1 year ago

Hi,

In the current release the logger is not working. It appears that you are not injecting the handler correctly. Affected code:

https://github.com/conekta/customer-magento-plugin/blob/d97be82aebec85136c3448a1cb84a4eae9f4f29e/Logger/Logger.php#L9-L20

I believe a more simple and standard way is to set up a logger is:

class Logger extends \Monolog\Logger
{

}

Where all implementation is handled by Monolog. Your di is already set up correctly for this to work: https://github.com/conekta/customer-magento-plugin/blob/d97be82aebec85136c3448a1cb84a4eae9f4f29e/etc/di.xml#L18-L30

You don't appear to be using the addRecord function of your logger, so that means that the debug adminpanel option has no effect. This could be rewritten if this is desired behaviour.

If no rewrite is desired, a quick fix is simply to pass the handler to the created instance of Monolog:

class Logger
{
    private const LoggerName = 'ConektaPaymentsLogger';
    /**
     * @var MonoLogger
     */
    private $monolog;

    public function __construct($name, $handlers)
    {
        $this->monolog = new MonoLogger(self::LoggerName, $handlers);
    }

This will also be enough to get the logger to work again.

Thank you.

fcarrero commented 1 year ago

Hi @MagicLegend thanks for reporting it, it will be fixed in the next version.

fcarrero commented 1 year ago

https://github.com/conekta/customer-magento-plugin/releases/tag/5.1.0