source: trunk/docs/services/debug.txt @ 462

Last change on this file since 462 was 437, checked in by lucadelu, 11 years ago

fix english, thank's to markus neteler

File size: 2.7 KB
Line 
1.. _services-debug:
2
3How To Debug ZOO Services
4=========================
5
6:Authors: Luca Delucchi
7:Last Updated: $Date: 2013-03-27 00:06:12 +0100 (Wed, 27 Mar 2013) $
8
9There are different ways to debug your services, the most used solutions are via web
10or via command line.
11
12Web
13----
14
15Using the web request you can see any problem in the log file of Apache.
16
17On Unix system the log file is usually in ``/var/log/apache2`` and the relevant file
18is ``error_log``. A simple way to read the file is to use the ``tail`` command,
19it permits to see the update of the file for each request ::
20
21  tail -f /var/log/apache2/error_log
22
23If the log is not clear enough you can add some more debug information to your code. You have to write
24to standard error.
25
26Python
27********
28Using Python, you can for example do this
29
30.. code-block:: python
31
32  import sys
33 
34  #add this line when you want see an own message
35  sys.stderr.write("My message")
36
37.. _web_javascript:
38
39Javascript
40************
41
42You can user ``alert`` to print a string to standard error:
43
44.. code-block:: javascript
45
46  // add this line when you want see an own message
47  alert('My message')
48  // you can debug value of inputs, outputs or conf
49  alert(inputs["S"]["value"])
50
51.. note:: If you try to pass an object it will only return ``[object Object]``
52
53Command line
54--------------
55
56It is possible to use the ZOO kernel ``zoo_loader.cgi`` also from command line.
57This is really useful to debug in a deeper way your service:
58
59.. code-block:: bash
60
61  # in order to use it you have to copy test_service.py and HelloPy.zcfg from
62  # the example services
63  ./zoo_loader.cgi "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
64
65Working this way you can use the standard debug system of the actual programming language used
66to develop your service.
67
68GDB
69*****
70From command line you can use also the command line tool `GDB <http://www.gnu.org/software/gdb/>`_
71to debug ``zoo_loader.cgi``, you have to run:
72
73.. code-block:: bash
74
75  # launch zoo_loader.cgi from gdb
76  gdb zoo_loader.cgi
77  # now run your request
78  run "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
79
80At this point you can ask help at the `ZOO mailing list <http://lists.osgeo.org/cgi-bin/mailman/listinfo/zoo-discuss>`_
81copying the result of the command.
82
83Python
84**********
85For Python, you can use ``pdb``, more info at http://docs.python.org/2/library/pdb.html
86
87.. code-block:: python
88
89  import pdb
90 
91  # add this line when you want investigate your code in more detail
92  pdb.set_trace()
93
94Javascript
95************
96
97You can use ``alert`` also to print in the console, more info in the :ref:`web_javascript` web section
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png