veptune Posted April 18 Share Posted April 18 Hello, I have real issues with logging exceptions / messages with Prestashop. For example I made a module and I got : The module testa is invalid and cannot be loaded. So I add some debug stuff, but no messages are displayed in the dev file (debug mode is enabled), even the "exit" has no effect. public function __construct() { $this->name = 'testa'; $this->version = '1'; $this->author = 'nico'; $this->bootstrap = true; $this->need_instance = 0; try { parent::__construct(); } catch (Exception $e) { echo $e->getTraceAsString(); } echo Tools::displayError('ÉEEEhec de l\'installation du module.'); echo "ERROR THERE"; exit(); } I can do : $this->logger = SymfonyContainer::getInstance()->get('logger'); $this->logger->info(sprintf('[%s] In %s', __CLASS__, __FUNCTION__)); but not in construct What is the best way to add debug messages and exceptions, wherever in the code? Thanks Link to comment Share on other sites More sharing options...
Knowband Plugins Posted April 18 Share Posted April 18 25 minutes ago, veptune said: even the "exit" has no effect. How did to conclude that your module code is being loaded? Are you able to see the module in the module list in the back office? Is the module enabled from the backend? Link to comment Share on other sites More sharing options...
veptune Posted April 18 Author Share Posted April 18 Yes, I can see it in the module list. And I got the error when I choose to install it. I clear cache every time I change something. Even if I add a typo in the code : public function __construct() { fgfdg ... I only got "The module testa is invalid and cannot be loaded." I confirm I'm sure I update the code of this module and not another else. Link to comment Share on other sites More sharing options...
Knowband Plugins Posted April 18 Share Posted April 18 40 minutes ago, veptune said: I confirm I'm sure I update the code of this module and not another else. Then, most probably issue is in the install function, not in the construct function. Link to comment Share on other sites More sharing options...
Webkul Solutions Posted April 29 Share Posted April 29 Hi, The issue may be due to an incorrect install() function or other implementation problems within your module. I would suggest that you please check the PrestaShop module documentation to ensure it follows the proper standards: https://devdocs.prestashop-project.org/8/modules/creation/tutorial/ Also, you can check the custom module generator provided by PrestaShop for reference: https://validator.prestashop.com/generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now