Jump to content

Nils-H

Recommended Posts

Until now, I've used "echo" and "print_r" to debug/log during development, but that is not code I want to have laying around in the code base when development is done. What I instead want, is something that is configurable, so debugging/logging can be enabled and displayed by switching a config option. Does PrestaShop come with built in support for something like this? Or what is the "idiomatic" way to do this with PHP/PrestaShop?

Link to comment
Share on other sites

Yes, I've seen that variable. However, searching through the code base of PrestaShop, it doesn't seem like this constant is used by very many components, so I was thinking that there might be another way that was preferred.

Link to comment
Share on other sites

Ok, but then, to where do you suggest I do logging? Switching logging on/off is just one piece of the puzzle. I have a bad feeling about echo'ing and print_r'ing everything directly to the html. That's fine for my own debugging purposes, while developing the modules. But I also want the users/installers of my modules to be able to send me traces of the execution (invoking web services, computation logic steps etc) when the module fails for some reason.

Link to comment
Share on other sites

Prestashop 1.5 has a built in Logger class (Logger.php) that writes in the PS_LOG table, maybe you can use it.

Logger::addLog(....)

 

It has also a FileLogger class in classes/log but it's not used anywhere.

 

It's not very difficult create your own system of logging into your module.

Edited by Enrique Gómez (see edit history)
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...