source: trunk/docs/services/debug.rst @ 728

Last change on this file since 728 was 725, checked in by djay, 9 years ago

Fix issue with rst files displayed from Trac. Fix strings to be translated. Always use the same string in all messages.

  • Property svn:keywords set to Date Author
  • Property svn:mime-type set to text/plain
File size: 3.1 KB
Line 
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
61programming language used to develop your service.
62
63In case you should simulate POST requests, you can use the following
64command to tell the ZOO-Kernel to use the file ``/tmp/req.xml`` as the
65input XML request:
66
67.. code-block:: guess
68
69    # Define required environment settings
70    export REQUEST_METHOD=POST
71    export CONTENT_TYPE=text/xml
72    # Run the request stored in a file
73    ./zoo_loader.cgi < /tmp/req.xml
74
75
76GDB
77*****
78From command line you can use also the command line tool `GDB <http://www.gnu.org/software/gdb/>`_
79to debug ``zoo_loader.cgi``, you have to run:
80
81.. code-block:: bash
82
83  # launch zoo_loader.cgi from gdb
84  gdb zoo_loader.cgi
85  # now run your request
86  run "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result"
87
88.. note::
89    You can use the same parameter used before to simulate POST
90    requests when running from gdb.
91
92If nothing helped, you can ask help at the `ZOO mailing list
93<http://lists.osgeo.org/cgi-bin/mailman/listinfo/zoo-discuss>`_
94copying the result of the command.
95
96Python
97**********
98For Python, you can use ``pdb``, more info at http://docs.python.org/2/library/pdb.html
99
100.. code-block:: python
101
102  import pdb
103 
104  # add this line when you want investigate your code in more detail
105  pdb.set_trace()
106
107Javascript
108************
109
110You 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