Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 213 forks source link

[ECP-8553] Custom log format #2148

Closed dimitriBouteille closed 1 year ago

dimitriBouteille commented 1 year ago

Is your feature request related to a problem? Please describe.

Would it be possible to add the possibility to modify the format of the logs?

By default Magento, uses the following format (in \Magento\Framework\Logger\Handler\Base).

$this->setFormatter(new LineFormatter(null, null, true));

Describe the solution you'd like

Add a new argument in \Adyen\Payment\Logger\Handler\AdyenBase class (ie: logFormat) and then modify this value via di.xml:

public function __construct(DriverInterface $filesystem, ?string $filePath = null, ?string $fileName = null, ?string $logFormat = null)
    {
        parent::__construct($filesystem, $filePath, $fileName);

        if ($logFormat) {
            $this->setFormatter(
                new \Monolog\Formatter\LineFormatter(
                    $logFormat
                )
            );

        }
    }

Describe alternatives you've considered

N/A.

Additional context

Some log tools need a specific format. In my case, I would like to have the following format: [%{time}] %{channel}.%{level}: %{message} Ctx|%{context}| Extra|%{extra}|.

candemiralp commented 1 year ago

Hello @dimitriBouteille,

Thank you for your suggestion. We created an internal investigation ticket to investigate the feasibility of this enhancement on the plugin. You will be informed when we conclude the investigation.

Best Regards, Can