How to trace Leo Core?

55 views
Skip to first unread message

Viktor Ransmayr

unread,
Sep 29, 2019, 3:43:19 PM9/29/19
to leo-editor
Hello Edward,

I tried to find out, if I can enable 'auditing/ tracing' for Leo in order to 'visualize' the run-time behavior of Leo Core ...

I started with something, that I thought should/ would be an easy starting point: I tried to audit/ trace what happens, when Leo opens an empty outline in a PyVE using:

* (Leo) PS C:\Users\Viktor\PyVE\PyPI\Leo\Lib\site-packages\leo\core> ./runLeo.py --trace=plugins ~/empty.leo

The result (Log-001) was not that helpfull. - Am I missing something?

With kind regards,

Viktor

---

<Start-Log-001>

Leo Log Window
Leo 6.0-final
Python 3.7.4, PyQt version 5.13.0
Windows 10 AMD64 (build 10.0.18362) SP0
current dir: C:/Users/Viktor/PyVE/PyPI/Leo/Lib/site-packages/leo/core
load dir: C:/Users/Viktor/PyVE/PyPI/Leo/lib/site-packages/leo/core
global config dir: C:/Users/Viktor/PyVE/PyPI/Leo/lib/site-packages/leo/config
home dir: C:/Users/Viktor
reading settings in C:/Users/Viktor/PyVE/PyPI/Leo/lib/site-packages/leo/config/leoSettings.leo
reading settings in C:/Users/Viktor/.leo/myLeoSettings.leo
loadOnePlugin: loaded: leo.plugins.plugins_menu
loadOnePlugin: loaded: leo.plugins.mod_scripting
loadOnePlugin: loaded: leo.plugins.viewrendered

<End-Log-001>

Brian Theado

unread,
Sep 29, 2019, 4:59:53 PM9/29/19
to leo-editor
Edward can speak to the built-in leo traces, but there are also other options.

I mentioned in the thread at https://groups.google.com/forum/#!topic/leo-editor/r6ktpQNWySk, about using the python trace module for debugging python applications, but I no longer recommend using it because it is too difficult to filter out noise. Since then I've discovered https://github.com/ionelmc/python-hunter and it is excellent. You can filter exactly which modules do and don't get traced and the colorized output looks nice.

Depending on what pattern of modules you pick to trace you will still get a firehose of information. You can either fine-tune your python-hunter queries more or just save the trace output to a file which you can search through.

But sometimes the approach Edward advocates in the above thread of modifying the code yourself and adding traces and using clones will be better. It's wise to heed his caution about signal to noise ratio :-).

Here is an example python hunter trace I've run on leo (after pip install hunter):

PYTHONHUNTER="module='leo.core.leoApp'" HOME=$HOME/tmp/blank ../pyqt-3.7-venv/bin/python launchLeo.py ~/tmp/new.leo

Here are some more example trace queries I've used:

PYTHONHUNTER="module_in=['leo.core.leoApp', 'leo.core.leoNodes']"
PYTHONHUNTER="~Q(kind='line'),module_in=['leo.core.leoApp', 'leo.core.leoNodes']"
PYTHONHUNTER="Q(module_startswith='leo')"

Here, I redirect to the pager program 'less' and do it in such a way as to not lose the color. By using less, I can search through the results (leo-bridge-test.py is just a file I was using to learn about leo bridge).

PYTHONHUNTER="Q(module_startswith='leo'),action=CallPrinter(force_colors=True)" HOME=$HOME/tmp/blank ../pyqt-3.7-venv/bin/python  leo-bridge-test.py 2>&1 | less -R

Not sure this is really what you are after, but I thought I'd share in case in helps.

Brian


--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/c89b189a-5aec-48d8-b312-65cba932a850%40googlegroups.com.

Viktor Ransmayr

unread,
Sep 30, 2019, 2:09:00 AM9/30/19
to leo-e...@googlegroups.com
Hello Brian,

Am So., 29. Sept. 2019 um 22:59 Uhr schrieb Brian Theado <brian....@gmail.com>:
Edward can speak to the built-in leo traces, but there are also other options.

I mentioned in the thread at https://groups.google.com/forum/#!topic/leo-editor/r6ktpQNWySk, about using the python trace module for debugging python applications, but I no longer recommend using it because it is too difficult to filter out noise. Since then I've discovered https://github.com/ionelmc/python-hunter and it is excellent. You can filter exactly which modules do and don't get traced and the colorized output looks nice.

Depending on what pattern of modules you pick to trace you will still get a firehose of information. You can either fine-tune your python-hunter queries more or just save the trace output to a file which you can search through.

...


Not sure this is really what you are after, but I thought I'd share in case in helps.

It's not exactly what I'm after, but your description - as well as - the README of python-hunter makes it clear, that this is an option I'll investigate further.

Thanks a lot for sharing!

With kind regards,

Viktor

Edward K. Ream

unread,
Sep 30, 2019, 5:04:58 PM9/30/19
to leo-editor
On Sun, Sep 29, 2019 at 2:43 PM Viktor Ransmayr <viktor....@gmail.com> wrote:

I tried to find out, if I can enable 'auditing/ tracing' for Leo in order to 'visualize' the run-time behavior of Leo Core ...

The various --trace options are good if they tell you what you want to see.

Usually, I put g.trace statements into Leo's source code.  A cff shows there are 414 nodes in Leo's code with such statements, so you shouldn't have too much trouble finding examples :-)

Edward

Edward K. Ream

unread,
Sep 30, 2019, 5:07:05 PM9/30/19
to leo-editor
On Sun, Sep 29, 2019 at 3:59 PM Brian Theado <brian....@gmail.com> wrote:
I've discovered https://github.com/ionelmc/python-hunter and it is excellent. You can filter exactly which modules do and don't get traced and the colorized output looks nice.

Thanks for this link.  I've bookmarked it.

Edward

Viktor Ransmayr

unread,
Oct 1, 2019, 2:17:45 AM10/1/19
to leo-e...@googlegroups.com
Hello Edward,

It looks like I was under the false impression, that Leo's code does have a 'verbose/ non-verbose' tracing mode available as well. - I had hoped, that if I use the 'verbose' tracing mode, Leo's modules would automatically leave their traces in the log ...

With kind regards,

Viktor

Reply all
Reply to author
Forward
0 new messages