.. _services-debug:
How To Debug ZOO Services
=========================
:Authors: Luca Delucchi
:Last Updated: $Date: 2013-03-27 00:06:12 +0100 (Wed, 27 Mar 2013) $
There are different ways to debug your services, the most used solutions are via web
or via command line.
Web
----
Using the web request you can see any problem with the log file of Apache.
On Unix system usually to log file is in ``/var/log/apache2`` and the useful file
is ``error_log``. A simple way to look inside the file is to use ``tail`` command,
it permits to see the update of the file for each request ::
tail -f /var/log/apache2/error_log
If the log is not so clear you can add some information inside your code. You have to write
in the standard error.
Python
********
Using Python for example you can do this
.. code-block:: python
import sys
#add this line when you want see your message
sys.stderr.write("My message")
.. _web_javascript:
Javascript
************
You can user ``alert`` to print a string to the standard error.
.. code-block:: javascript
// add this line when you want see your message
alert('My message')
// you can debug value of inputs, outputs or conf
alert(inputs["S"]["value"])
.. note:: If you try to pass an object it return only ``[object Object]``
Command line
--------------
It is possible to use the ZOO kernel ``zoo_loader.cgi`` also from command line.
This is really useful to debug in a deeper way your service.
.. code-block:: bash
# to use it you have to copy test_service.py and HelloPy.zcfg from
# the example services
./zoo_loader.cgi "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
Using this way you can use standard debug system of the programming language used
in your service.
GDB
*****
From command line you can use also the command line tool `GDB `_
to debug ``zoo_loader.cgi``, you have to run
.. code-block:: bash
# launch zoo_loader.cgi from gdb
gdb zoo_loader.cgi
# now run your request
run "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
At this point you can ask help to the `ZOO mailing list `_
copying the result of the command.
Python
**********
For Python you can use ``pdb``, more info at http://docs.python.org/2/library/pdb.html
.. code-block:: python
import pdb
# add this line when you want investigate more in the code
pdb.set_trace()
Javascript
************
You can use ``alert`` also to print in the console, more info in the :ref:`web_javascript` web section