Jump to content

tracing problems, debugging, syslog


Recommended Posts

Hi,

i'm new to prestashop and wonder how one goes about tracing or debugging.
My first attempt was do add some syslog statements to the code (since I run on Linux):

openlog("prestashop", LOG_PID, LOG_USER);
syslog(LOG_INFO, "some thing()");

What are the alternatives? I didn't see a way of logging all queries, or enabling tracing logging to debug?

With syslog I then have to add all my own statements are then remove afterwards.
Link to comment
Share on other sites

Damien:
- where does one enable the smarty debug mode
- xdebug sounds interesting, didn't know about that.
- you don't use syslog then? Apache log? browser?

Would it not be interesting to have debugs statements sprinkled throughout the code and enable varying debugs levels with a simple config parameter?
(I'd started on a Logger class in a previous project: http://opennac.svn.sourceforge.net/viewvc/opennac/branches/3.0/lib/Logger.php?view=log)

Each time you do an upgrade you lose all of your Debug statements?

I'm new to PS so excuse me if this is all obvious for others.

Skipper: well thats something new. I know firebug (pity it does not yet work on FF3), but had not heard of the FirePHP extension. Sounds better than syslog for windows servers, or servers with no console access.
How do you manage upgrades (preserving debugs), and enabling different debug levels?
Does it affect performance, would you use it to log queries for example?

Link to comment
Share on other sites

Boran, FirePHP is just like syslog, only to the browser. Which makes it particularily useful for webdevelopment. I have never noticed any performance hit, at least not on the server. For the client, this is a different story and depends on the amount of log data.

Upgrades are a different subject, at least to me:
- First of all, and in this specific case, I consider PS extremely bad written from that point of view. As long as templates are splattered all around, most notibly in the modules, PS customization is heavily restricted. PS is using OO, but offers no way to safely extend objects. PS offers a bugtracker, but no feedback about fixes. Stable releases are declared to be "free of significant bugs". The list goes on ... only to say that you should find a organizational solution to the technical shortcomings.

My solution is a multi-stages git. I have the stable in trunk, branch into "changes" and work there. At a next stable, I make a diff between former stable and "changes" and try to apply the diff against the new stable. I recommend git over subversion because branch operations are far cheaper and faster.

Keeping debug statements is a strange idea to me: I debug when I have a problem, once fixed I don't need them anymore, so I kick them out. If you want to keep info, dump them to a file. If you want permanent, but not necessarily continuous access, and have server access, then look at something like nettail, whick you can find on Gna.

Link to comment
Share on other sites

While I agree with Skipper that I tend to remove debug code once I (think!!) I've got the code working properly, I recently found myself wishing there as some sort of "event" log or such that could be tapped into.

In this case it was for a payment module, where it would be nice to put unexpected responses etc. somewhere to allow some form of debugging. I guess you could write a logging function into every module that needs the functionality, but I think it would be nice to be able to capture certain events somewhere in a consistent manner, and write them to the database so that non-technical store owners could access them and pass them on for support elsewhere.

Currently there's a lot of events (particularly/specifically to do with payment modules though) that would benefit. It would mainly be used for integration, so it would also be good to be able to turn the functionality off. This isn't so much for debugging your own code, as allowing store owners to debug the interface with the payment processor.

Paul

Link to comment
Share on other sites

  • 2 months later...

As I work more and more with PS, I keep coming back to the debugging issue, and feel it should be possible to keep debug code and enabled when needed.

Anyway, I was digging for a way to tie in FirePHP very simply in any class I needed. Trying the OO didn't work to well, but this did:

in config/config.inc.php, add

include_once(dirname(__FILE__) .'/../FirePHPCore/fb.php');  


extract FirePHPCore into the shop root.

And from any line a module (for example), add a debug print like this

fb('hello');
Link to comment
Share on other sites

  • 1 year later...

I would like to build on boran's instructions, just to be clear:

extract FirePHPCore folder into the shop root.
in config/config.inc.php, add:

include_once(dirname(__FILE__) .'/../FirePHPCore/fb.php');  



And on any line of a module (for example), create your debug statements like so:

$firephp = FirePHP::getInstance(true);
$firephp->log('just a message');
$firephp->log($some_var, 'some var name');



You need:
- firefox
- firebug extension
- firephp extension
- make sure NET and CONSOLE panels are turned on in firebug

More information here

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...
  • 2 weeks later...
For smarty you can use the debug mode.
For PHP I use xdebug (a php extension).
For the database I log queries myself by adding a few lines in /classes/MySQL.php.
And of course firebug for everything else, but it's more debug than trace.



Hi Damien Metzger!

Could you share how you log your SQL queries?

For the database I log queries myself by adding a few lines in /classes/MySQL.php.


Could you please share this lines of codes? Does it log all SQL queries done in the site?

Thank you!
Link to comment
Share on other sites

Nothing seems to be done in Prestashop so as to log queries ...
Bandai, I guess you'll need to declare a variable such as "$debug=true; // or $debug=false;
and in your MySQL.php file, check that variable before executing queries ... and log what you need in your log file if that variable is set to true :-(
But as everything in Prestashop ... when changing that part of the code ... you'll have to make file merges for updates.

The easier for you will be to get Damien's MySQL.php file if you don't wanna take 10 minutes to do it yourself.

Link to comment
Share on other sites

I already have an idea on how to do this but I'm not sure if it's the correct way to go about this.

I've checked classes/MySQL.php file and their are different function that process SQL queries like:

* getValue
* Execute
* ExecuteS
ect..

Do I modify each function to put in the check for logging the queries? or there is a simpler way to do this? That's why I am interested in what Damien came up with, maybe he have done something simple that I miss.

Link to comment
Share on other sites

I will, I'm trying to send Damien a message but his mailbox is full. Hopefully he reads this thread and reply.

For the mean time I'm going to look for other ways to do this and if I found a nice and simple way to log all queries I'll post it here.

Link to comment
Share on other sites

  • 7 months later...
×
×
  • Create New...