source:
branches/PublicaMundi_David-devel/docs/services/debug.rst
@
725
Last change on this file since 725 was 717, checked in by djay, 9 years ago | |
---|---|
|
|
File size: 3.1 KB |
Debugging ZOO Services
Several methods can be used in order to debug :ref:`services_index`. The most common solutions are web or command line.
Web
Any problem can be checked in the Apache server log file when using http WPS requests.
On Unix, the log files is usually located in /var/log/apache2 and the relevant one is named error_log. A simple way to read this file is to use the tail command, as it allows to see the file updates for each request
tail -f /var/log/apache2/error_log
If the log is not clear enough, you still have the possibility to add more debug information to your source code, writing to standard errors.
Python
Using Python, you can for example do this:
import sys #add this line when you want see an own message sys.stderr.write("My message")
Javascript
Using JavaScript, you can use alert to print a string to standard error, for example:
// add this line when you want to see own 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 will only return [object Object]
Command line
:ref:`kernel_index` (zoo_loader.cgi) can also be used from command line. This is really useful for debugging services in a deeper way, for example:.
# in order 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"
Working this way you can use the standard debug system of the actual programming language used to develop your service.
In case you should simulate POST requests, you can use the following command to tell the ZOO-Kernel to use the file /tmp/req.xml as the input XML request:
GDB
From command line you can use also the command line tool GDB to debug zoo_loader.cgi, you have to run:
# 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"
Note
You can use the same parameter used before to simulate POST requests when running from gdb.
If nothing helped, you can ask help at 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
import pdb # add this line when you want investigate your code in more detail pdb.set_trace()
Javascript
You can use alert also to print in the console, more info in the :ref:`web_javascript` web section