Jump to content

Logging error messages and exception in PS


veptune

Recommended Posts

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

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

  • 2 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...