Javascript 如何测试/调试 GNOME Shell 扩展?有什么工具可以做到这一点吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8425616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to test / debug GNOME Shell extensions? Is there any tool for that?
提问by marcio
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.
我想开发 GNOME Shell 扩展,发现进入开发过程真的很容易,但我仍然不知道如何有效地调试/测试我的扩展。
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?
是否有任何工具可用于此目的?有没有像我们在现代浏览器或 javascript 服务器环境中那样的实时控制台?
回答by ptomato
Yes, the real-time console is called "Looking Glass" and can be started by pressing Alt+F2and typing lg
at the prompt.
是的,实时控制台称为“Looking Glass”,可以通过按Alt+F2并lg
在提示符下键入来启动。
回答by jsnHyman
On Fedora 20 (and probably any new linux distro) you can use that command:
在 Fedora 20(可能还有任何新的 linux 发行版)上,您可以使用该命令:
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.
它不断地 ( -f
) 在终端窗口中打印由 gnome-session 生成的错误。我更喜欢-o cat
flag,因为它显示没有时间戳的完整消息。
On Fedora 22, I believe, it was replaced with:
我相信在 Fedora 22 上,它被替换为:
journalctl /usr/bin/gnome-shell -f -o cat
回答by Geoff
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.
窥镜很棒。但是,如果您需要一个直接的控制台,您可以得到一个,但不能通过 LG,至少从 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.
如果您弹出一个终端并输入gnome-shell --replace
,gnome-shell 将从那里运行,替换正在运行的实例,然后全局日志输出将出现在该控制台中。
You can test it with Looking Glass by doing Alt-F2lg
, and thenglobal.log("foo")
in the "Evaluator" tab.
您可以通过执行Alt- F2lg
,然后global.log("foo")
在“评估器”选项卡中使用窥镜来测试它。
回答by The_Cute_Hedgehog
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.
我更喜欢阅读 ~/.xsession-errors
和~/.cache/gdm/session.log
文件以获取更多详细信息。某些错误消息可能与其他异常或错误有关。
回答by Rik
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
- thenr
andenter
, when that happens - the terminal-run session will end automatically (at least on Debian).I'd recommend jsnHyman'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.
对于 Geoff 回答的评论 2,只需通过
alt+f2
- thenr
和重新启动外壳enter
,当发生这种情况时 - 终端运行会话将自动结束(至少在 Debian 上)。我推荐 jsnHyman 的一般调试答案,它也适用于 Debian Jessy;可能想要
sudo
那个。它会在您运行它的任何终端中显示 gnome 错误以及 global.log() 消息。
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.
如果有的话,这为我提供了一个更完整的参考 - 因为我在参考信息时不止一次遇到过这个页面,我不记得了。
回答by hugo der hungrige
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:
如果您不知道 gnome 会话的正确路径,您还可以使用:
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.
为什么它不起作用可能是因为我的 gnome-session-binary 路径不同,这可能与安装的 gnome 的新版本有关。
回答by ILMostro_7
AnjutaDev-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
AnjutaDev-Studio 是使用 gnome-shell 扩展的绝佳工具;它配备了调试器、GUI 设计器、版本控制等。在 gnome 的wiki 页面上,甚至还有一个指导教程,用于将 Anjuta 与 gnome-shell 扩展项目一起使用
回答by olejorgenb
We are developing a emacs package aimed at gnome-shell extension development here: https://github.com/paperwm/gnome-shell-mode
我们正在这里开发一个针对 gnome-shell 扩展开发的 emacs 包:https: //github.com/paperwm/gnome-shell-mode
It's still in "beta" (dec. 2017), but its already very useful.
它仍处于“测试版”(2017 年 12 月),但已经非常有用。
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
- 自动完成(比窥镜提供的好得多)
- 行、选择、当前函数、缓冲区的评估(可选择将结果粘贴到缓冲区的注释中)
- 评估时突出显示错误
- 文档查找助手
- 无需重新启动 gnome-shell 即可重新加载您正在处理的模块的助手