3.3 KiB
Tools for debug
INFO_DEBUG
Show debugging information in a message box.
If you have any problems in your code during the development of your macros, you can open a ticket support in the system ticket of this project. Always copy the debugging information shown in your issue.
import easymacro as app
def info():
app.msgbox(app.INFO_DEBUG)
return
debug
Show information at the terminal.
import easymacro as app
def test_debug():
msg = 'Verify this information...'
app.debug(msg)
return
To view this message, you need to start LibreOffice from the command line:
soffice --calc
After executing the previous macro, you should see:
21/04/2023 17:04:49 - DEBUG - Verify this information...
info
Show information messages at the terminal.
import easymacro as app
def test_info():
msg = 'Starting process...'
app.info(msg)
return
11/08/2022 18:23:53 - INFO - Starting process...
error
Show error messages at the terminal.
import easymacro as app
def test_error():
msg = 'Error 505'
app.error(msg)
return
11/08/2022 18:27:34 - ERROR - Error 505
save_log
Save log in file, automatically add date and time.
import easymacro as app
def test_save_log():
app.save_log('/home/mau/log.txt', 'PyUNO')
app.save_log('/home/mau/log.txt', 'World Damn')
return
cat ~/log.txt
2022-08-11 18:30:11 - 'PyUNO'
2022-08-11 18:30:11 - 'World Damn'
msgbox
Show any information in a message box.
import easymacro as app
def message():
msg = 'Please, consume less.'
app.msgbox(msg)
msg = ('one', 2, 'three')
app.msgbox(msg)
msg = {'name': 'Teresa'}
app.msgbox(msg)
app.msgbox(app)
return
catch_exception
Capture any error that occurs when running a macro.
!!! warning inline end "Caution"
Use this method only in development time. **Do not use it in production**.
import easymacro as app
@app.catch_exception
def test_capture_error():
r = 1 / 0
return
11/08/2022 18:44:36 - ERROR - test_capture_error
Traceback (most recent call last):
File "/home/mau/.config/libreoffice/4/user/Scripts/python/pythonpath/easymacro/easytools.py", line 115, in func
return f(*args, **kwargs)
File "/home/mau/.config/libreoffice/4/user/Scripts/python/test.py", line 18, in test_capturar_error
r = 1 / 0
ZeroDivisionError: division by zero
mri
MRI is the best extension to inspect any UNO LibreOffice object. You need to install it first so you can use it.
import easymacro as app
def inspect_object():
obj = app.active
app.mri(obj)
return
inspect
Inspect an object.
import easymacro as app
def inspect_object():
doc = app.active
data = app.inspect(doc)
for p in data.properties:
app.debug(p)
for m in data.methods:
app.debug(m)
return
Send information of the object to worksheet.
def inspect_object():
doc = app.active
app.inspect(doc, True)
return