debugging server service code

debugging server service code

am 12.04.2008 10:29:51 von liketofindoutwhy

usually it is handy to debug PHP programs using print_r() or
var_dump(), as they can print out all the variables you need and the
web browser can show any run time error message. But what if it is
the situation when the php file is providing info to the Javascript
either as an AJAX call or even more so, as an OpenSocial's service --
in those case, there is a bunch of parameters provided to the PHP file
and it is really hard to mimic a session using
http://www.oursite.com/getData.php?auth_token=3424242345... with
possible data posted to the PHP file.

In those situation, we can write any variable to a file using
var_export() and a write function as a debug log... but what if there
is any run time error... is there a way to redirect all those info
also to a file, or somehow be able to see the run time error and stack
trace?

Any possible solution? Thanks for your help!

Re: debugging server service code

am 12.04.2008 15:24:29 von Jerry Stuckle

liketofindoutwhy@gmail.com wrote:
> usually it is handy to debug PHP programs using print_r() or
> var_dump(), as they can print out all the variables you need and the
> web browser can show any run time error message. But what if it is
> the situation when the php file is providing info to the Javascript
> either as an AJAX call or even more so, as an OpenSocial's service --
> in those case, there is a bunch of parameters provided to the PHP file
> and it is really hard to mimic a session using
> http://www.oursite.com/getData.php?auth_token=3424242345... with
> possible data posted to the PHP file.
>
> In those situation, we can write any variable to a file using
> var_export() and a write function as a debug log... but what if there
> is any run time error... is there a way to redirect all those info
> also to a file, or somehow be able to see the run time error and stack
> trace?
>
> Any possible solution? Thanks for your help!
>
>

You can set a log file in your php.ini file which will log php-detected
errors instead of displaying them.

I have it on on my development system, just so I can go back and look at
the errors if I need to. I just clean it up every few days (I make LOTS
of typing errors :-)= ).

It's also a good idea to have it on your production system and check it
on a regular basis to ensure there are no unexpected errors. I
generally have a cron job check the size and mail it to me of non-zero
on a daily basis, then rotate it with the rest of the log files.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: debugging server service code

am 12.04.2008 23:23:29 von Paul Lautman

liketofindoutwhy@gmail.com wrote:
> usually it is handy to debug PHP programs using print_r() or
> var_dump(), as they can print out all the variables you need and the
> web browser can show any run time error message. But what if it is
> the situation when the php file is providing info to the Javascript
> either as an AJAX call or even more so, as an OpenSocial's service --
> in those case, there is a bunch of parameters provided to the PHP file
> and it is really hard to mimic a session using
> http://www.oursite.com/getData.php?auth_token=3424242345... with
> possible data posted to the PHP file.
>
> In those situation, we can write any variable to a file using
> var_export() and a write function as a debug log... but what if there
> is any run time error... is there a way to redirect all those info
> also to a file, or somehow be able to see the run time error and stack
> trace?
>
> Any possible solution? Thanks for your help!

Further to Jerry's suggestions, you can also setup your own error handler
using
set_error_handler()