Jump to content

Edit History

rpommier

rpommier

Hi all,

 

Before using Prestashop 1.7, for my Prestashop commands, I used $logger = new ConsoleLogger($output); before call $logger->warn(...);.

With Prestahsop 1.7, I use the dependency injection, and in the constructor of the class, I call LoggerInterface :

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;

class NextpharmStockUpdateCommand extends Command
{
    private LoggerInterface $logger;

    public function __construct(LoggerInterface $logger)
    {
        parent::__construct('my:module:command');

        $this->logger = $logger;
    }
}

Basically, that seems work, but the logger used is PrestaShopLogger, which write in database (ps_log) and by default checks if there is already the message in ps_log (SELECT COUNT(*) FROM ps_log WHERE message='...'). In my case (update stock of all [~15000] products), the execution was ~5 minutes and is now >4h.

Is someone know, for commands, use ConsoleLogger for LoggerInterface instead of PrestaShopLogger?

Thanks!

rpommier

rpommier

Hi all,

 

Before using Prestashop 1.7, for my Prestashop commands, I used `$logger = new ConsoleLogger($output);` before call `ogger->warn(...);`.

With Prestahsop 1.7, I use the dependency injection, and in the constructor of the class, I call `LoggerInterface` :

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;

class NextpharmStockUpdateCommand extends Command
{
    private LoggerInterface $logger;

    public function __construct(LoggerInterface $logger)
    {
        parent::__construct('my:module:command');

        $this->logger = $logger;
    }
}

Basically, that seems work, but the logger used is PrestaShopLogger, which write in database (ps_log) and by default checks if there is already the message in ps_log (`SELECT COUNT(*) FROM ps_log WHERE message='...'). In my case (update stock of all [~15000] products), the execution was ~5 minutes and is now >4h.

Is someone know, for commands, use ConsoleLogger for LoggerInterface instead of PrestaShopLogger?

Thanks!

×
×
  • Create New...