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

久未见 提交于 2019-11-28 18:14:37

问题


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?


回答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




回答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



回答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.




回答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.




回答5:


I can't comment on other answers yet, so thought I'd add - however late it may be:

  • For comment 2 of Geoff's answer, just restart the shell via alt+f2 - then r and enter, when that happens - the terminal-run session will end automatically (at least on Debian).

  • I'd recommend jsnjack's answer for general debugging, which works with Debian Jessy as well; probably want to sudo that though. It'll show gnome errors, as well as global.log() messages in whichever terminal you run it in.

If anything, this provides a more complete reference for me - as I've come across this page more than once when referencing info I don't keep fresh in my memory.




回答6:


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.




回答7:


Anjuta Dev-Studio is a great tool for working with gnome-shell extensions; it comes equipped with a debugger, GUI designer, version control, and more. There's even a guided tutorial for using Anjuta with gnome-shell extension projects over on gnome's wiki-pages




回答8:


We are developing a emacs package aimed at gnome-shell extension development here: https://github.com/paperwm/gnome-shell-mode

It's still in "beta" (dec. 2017), but its already very useful.

Features

  • Autocompletion (muuuch better than what looking glass provides)
  • Eval of line, selection, current function, buffer (optionally pasting the result into the buffer in a comment)
  • Highlight of error when evaling
  • Documentation lookup helper
  • Helper to reload the module you're working on without restarting gnome-shell


来源:https://stackoverflow.com/questions/8425616/how-to-test-debug-gnome-shell-extensions-is-there-any-tool-for-that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!