Search the Community
Showing results for tags 'logger'.
-
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!
- 1 reply
-
- prestashop 1.7
- logger
-
(and 1 more)
Tagged with:
-
Hello, An object, used by my module had this code : private function fetchData($exporter) { $fetched_data = file_get_contents($exporter->getFetchFullUrl()); \Logger::addLog("fetching from " . $exporter->getFetchFullUrl(), 1, null, null, null, true); return $fetched_data; } But it now throw an exception : UndefinedMethodException on the \Logger line. So I replace it with this code : public function __construct($definition_class_name) { $this->logger = new LegacyLogger(); ... } and private function fetchData($exporter) { $fetched_data = file_get_contents($exporter->getFetchFullUrl()); $this->logger->info("fetching from " . $exporter->getFetchFullUrl()); return $fetched_data; } That works fine. However, I'd like to know if this is the correct way to do it. Is it ? Can I rely on some dependency injection ? Or rely on (global) Container ?
- 2 replies
-
- dependency injection
- 1.7.4
-
(and 2 more)
Tagged with: