source: branches/PublicaMundi_David-devel/docs/services/debug.rst @ 684

Last change on this file since 684 was 659, checked in by nbozon, 10 years ago

Massive update of zoo docs

File size: 2.7 KB
RevLine 
[659]1.. _services-debug:
2
3Debugging ZOO Services
4=========================
5
6Several methods can be used in order to debug :ref:`services_index`. The most common solutions are web or command line.
7
8Web
9----
10
11Any problem can be checked in the Apache server log file when using http WPS requests.
12
13On Unix, the log files is usually located in ``/var/log/apache2`` and
14the relevant one is named *error_log*. A simple way to read this file is to use the ``tail`` command,
15as it allows to see the file updates for each request ::
16
17  tail -f /var/log/apache2/error_log
18
19If the log is not clear enough, you still have the possibility to add
20more debug information to your source code, writing to standard errors.
21
22Python
23********
24Using Python, you can for example do this:
25
26.. code-block:: python
27
28  import sys
29 
30  #add this line when you want see an own message
31  sys.stderr.write("My message")
32
33.. _web_javascript:
34
35Javascript
36************
37
38Using JavaScript, you can use ``alert`` to print a string to standard error, for example:
39
40.. code-block:: javascript
41
42  // add this line when you want to see own message
43  alert('My message')
44  // you can debug value of inputs, outputs or conf
45  alert(inputs["S"]["value"])
46
47.. note:: If you try to pass an object it will only return ``[object Object]``
48
49Command line
50--------------
51
52: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:.
53
54.. code-block:: bash
55
56  # in order to use it you have to copy test_service.py and HelloPy.zcfg from
57  # the example services
58  ./zoo_loader.cgi "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
59
60Working this way you can use the standard debug system of the actual programming language used
61to develop your service.
62
63GDB
64*****
65From command line you can use also the command line tool `GDB <http://www.gnu.org/software/gdb/>`_
66to debug ``zoo_loader.cgi``, you have to run:
67
68.. code-block:: bash
69
70  # launch zoo_loader.cgi from gdb
71  gdb zoo_loader.cgi
72  # now run your request
73  run "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
74
75At this point you can ask help at the `ZOO mailing list <http://lists.osgeo.org/cgi-bin/mailman/listinfo/zoo-discuss>`_
76copying the result of the command.
77
78Python
79**********
80For Python, you can use ``pdb``, more info at http://docs.python.org/2/library/pdb.html
81
82.. code-block:: python
83
84  import pdb
85 
86  # add this line when you want investigate your code in more detail
87  pdb.set_trace()
88
89Javascript
90************
91
92You 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

Context Navigation

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