zaz/doc/source/main/tools_for_debug.rst

154 lines
2.3 KiB
ReStructuredText

Tools for debug
---------------
**INFO_DEBUG**
^^^^^^^^^^^^^^
Show info debug, show in message box.
If you have any problem in your code, you can `open issue`_ in this project,
always copy the information of INFO_DEBUG in your ticket.
.. code-block:: python
import easymacro as app
def info():
app.msgbox(INFO_DEBUG)
return
Show in shell.
.. code-block:: python
import easymacro as app
def info():
app.debug(INFO_DEBUG)
return
**Log error**
^^^^^^^^^^^^^
Show error message in shell.
.. code-block:: python
import easymacro as app
def error():
msg = 'My error 500'
app.error(msg)
return
**Log debug**
^^^^^^^^^^^^^
Show debug message in shell.
.. code-block:: python
import easymacro as app
def error():
msg = 'Verify this data...'
app.debug(msg)
return
**Log info**
^^^^^^^^^^^^
Show info message in shell.
.. code-block:: python
import easymacro as app
def error():
msg = 'Start process...'
app.info(msg)
return
**Log to file**
^^^^^^^^^^^^^^^
Save log to file, automatic add date and time.
.. code-block:: python
import easymacro as app
def log():
app.save_log('/home/mau/log.txt', 'PyUNO')
app.save_log('/home/mau/log.txt', app.INFO_DEBUG)
return
**Message box**
^^^^^^^^^^^^^^^
Show any data in message box
.. code-block:: python
import easymacro as app
def message():
msg = 'Please, save the planet'
app.msgbox(msg)
msg = ('one', 2, 'three')
app.msgbox(msg)
msg = {'name': 'Teresa'}
app.msgbox(msg)
app.msgbox(app)
return
**Catch exceptions**
^^^^^^^^^^^^^^^^^^^^
Sometimes, for difficult errors, you can catch exceptions.
.. code-block:: python
import easymacro as app
@app.catch_exception
def test():
r = 1 / 0
return
And not, not used you this function in production.
**Call MRI**
^^^^^^^^^^^^
`MRI`_ is the better extension for debug any object in LibreOffice, you need
install before call it.
.. code-block:: python
import easymacro as app
def error():
obj = app.active
app.mri(obj)
return
.. _MRI: https://github.com/hanya/MRI
.. _open issue: https://git.cuates.net/elmau/zaz/issues