How to test / debug GNOME Shell extensions? Is there any tool for that?

37,802

Solution 1

Yes, the real-time console is called "Looking Glass" and can be started by pressing Alt+F2 and typing lg at the prompt.

More info: https://live.gnome.org/GnomeShell/LookingGlass

Solution 2

On Fedora 20 (and probably any new linux distro) you can use that command:

journalctl /usr/bin/gnome-session -f -o cat

It constantly (-f) prints errors generated by gnome-session in terminal window. I prefer -o cat flag as it shows full messages without timestaps.

On Fedora 22, I believe, it was replaced with:

journalctl /usr/bin/gnome-shell -f -o cat

Solution 3

Looking Glass is great. If you need a straight console, though, you can get one, but not through LG, at least not as of 3.6.

If you pop open a terminal and type gnome-shell --replace, gnome-shell will run from there, replacing the running instance, and global log output will thereafter appear in that console.

You can test it with Looking Glass by doing Alt-F2 lg, and thenglobal.log("foo") in the "Evaluator" tab.

Solution 4

I prefer reading ~/.xsession-errors and ~/.cache/gdm/session.log files for more detail. Some of the error messages might have a relation with other exceptions or errors.

Solution 5

The other answers didn't really work for me while developing my own extension. What did however was:

journalctl /usr/lib/gnome-session/gnome-session-binary -f -o cat 

If you want to declutter the output to just see your app, you can use:

journalctl /usr/lib/gnome-session/gnome-session-binary -f -o cat | grep [myAppId]

If you also want to access non error logs using the above method above you can use:

global.log('[myAppId]', valueToLog);

If you don't know the correct path to your gnome session you can also use:

journalctl -f | grep gnome-session

Why it was not working is probably because of my gnome-session-binary path was different, which might be related to a newer version of gnome being installed.

Share:
37,802

Related videos on Youtube

marcio
Author by

marcio

Contributor of many open source projects. Languages I work with: PHP Go Python Lisp Rebol and Red C (learning) C++ (learning)

Updated on July 05, 2022

Comments

  • marcio
    marcio 5 months

    I would like to develop GNOME Shell extensions and found it's really easy to step into the development process but I still can't figure out how to debug / test my extensions effectively.

    Are there any tools for that purpose? Is there any kind of real time console like we have on modern browsers or javascript servers environments?

  • perimosocordiae
    perimosocordiae over 9 years
    When I cancelled gnome-shell after using the approach, everything froze except for my mouse. I had to hard restart my machine to get it working again.
  • Erick Robertson
    Erick Robertson almost 9 years
    @User231371 would like to point out: In Ubuntu gnome, log are in ~/.cache/upstart/gnome-session.log .
  • sharat87
    sharat87 over 8 years
    That's because you killed your only instance of gnome-shell. Instead of killing it with C-c when you're done, hit C-z to suspend it. Then type bg<CR> into the console (you may not see what you are typing when typing this command) and then gnome-shell will run in the background. Next, run disown <Tab><CR> to detach the process from the terminal window, after which you can safely close the terminal window.
  • marcio
    marcio over 8 years
    This is much better than gnome-shell --replace since id doesn't attaches a gnome shell session to a terminal :)
  • Toni Chaz
    Toni Chaz over 5 years
    On ubuntu wokrs too
  • akaihola
    akaihola almost 5 years
    On Fedora 26, the correct path is /etc/libexec/gnome-session-binary.
  • akaihola
    akaihola almost 5 years
    However, global.log() messages don't turn up in journalctl output, nor in Looking Glass. Is logging perhaps off by default on Fedora 26?
  • akaihola
    akaihola almost 5 years
    Instead, log messages do show up in journalctl /usr/bin/gnome-shell.
  • SO_fix_the_vote_sorting_bug
    SO_fix_the_vote_sorting_bug over 3 years
    How does the debugger work? Anjuta doesn't even run the extension in any intuitive fashion, it only prints errors. And the wiki link says nothing about Anjuta except that it exists and to recommend not using it!
  • ILMostro_7
    ILMostro_7 over 3 years
    Not sure if the page had changed. You can check other relevant pages for working with the debugger in anjuta; e.g. developer.gnome.org/anjuta-manual/stable/debug-tips.html.en
  • Sombriks
    Sombriks about 1 year
    not working on fedora 34/wayland. need to restart session.

Related