Nils-H Posted August 8, 2013 Share Posted August 8, 2013 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 More sharing options...
El Patron Posted August 8, 2013 Share Posted August 8, 2013 ps uses define('_PS_MODE_DEV_', true); in cofig/defines.inc.php you could base your development code on this value if you like 1 Link to comment Share on other sites More sharing options...
Nils-H Posted August 8, 2013 Author Share Posted August 8, 2013 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 More sharing options...
NemoPS Posted August 12, 2013 Share Posted August 12, 2013 I second El Patron. Yes it's not documented, but that's usually how you debug prestashop, so you can use your code based on that value as well Link to comment Share on other sites More sharing options...
Nils-H Posted August 13, 2013 Author Share Posted August 13, 2013 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 More sharing options...
Enrique Gómez Posted August 13, 2013 Share Posted August 13, 2013 (edited) 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 August 13, 2013 by Enrique Gómez (see edit history) Link to comment Share on other sites More sharing options...
Nils-H Posted August 13, 2013 Author Share Posted August 13, 2013 True, I was looking into log4php and other solutions, but wanted to know if there was something that existed in PS already. I'll look into the Logger class you mentioned. Thanks! 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