定制firefox console.log(为我自己的原型) [英] customizing firefox console.log (for my own prototype)

查看:260
本文介绍了定制firefox console.log(为我自己的原型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个(自由软件)应用程序(MELT监视器,在GNU / Linux / Debian / x86-64上),它嵌入了特定的Web服务器。

请参阅这个问题了解更多细节。如果有兴趣,请在github上查看提交 880419d370d749 然后构建它,运行 ./ monimelt -Dweb,运行-W localhost.localdomain:8086 / 并打开 http://localhost.localdomain:8086 / canvedit.html 在您的Firefox。 FWIW我现在正在尝试使用画布。相关的代码可能会在我的 webroot / canvasedit.js ,但我不知道在那里编写代码...

Firefox是38或42版。我不明白所有 ConsoleAPI.js <一个>这可能是非常相关的我的问题。

假设我有一个原型

  var fooproto = {
//也许在这里添加一个toString函数就够了?
//我想显示num&儿子
};

然后我使用它来创建一些对象:

  var foo1 = Object(); 
foo1.num = 11;
foo1 .__ proto__ = fooproto;

var foo2 = Object();
foo2.num = 37;
foo2.sons = [foo1];
foo2 .__ proto__ = fooproto;

我想

  console.log(foo2 =,foo2); 

显示类似于 foo2 = Foo#37 [Foo#11] 在控制台上(如果可能的话用斜体)

有没有办法改变 fooproto 使这个工作?我猜有些机制存在,因为 console.log 显示的是很好的DOM对象。



可能是一个FAQ问了很多次,但是我经过几分钟的搜索才找到合适的搜索关键词,我不知道使用什么术语 解决方案

我不是为Firefox开发的,我已经看到了这一点,但我偶然发现这一点:



好像有些东西可能回答您的需求。

I'm coding a (free software) application (the MELT monitor, on GNU/Linux/Debian/x86-64) which embeds its specific web server.

See this question for gory details. If interested, look into commit 880419d370d749 on github then build it, run ./monimelt -Dweb,run -W localhost.localdomain:8086/ and open http://localhost.localdomain:8086/canvedit.html in your Firefox. FWIW I'm now trying to use canvases. Relevant code might go in my webroot/canvasedit.js, but I don't know what to code there yet...

Firefox is version 38 or 42. I don't understand all the details of ConsoleAPI.js which probably is very relevant to my question.

Let suppose I have a prototype

var fooproto = {
  // perhaps adding a toString function is enough here?
  // I want to show num & sons
};

then I make some objects using it:

var foo1 = Object();
foo1.num = 11;
foo1.__proto__ = fooproto;

var foo2 = Object();
foo2.num = 37;
foo2.sons = [foo1];
foo2.__proto__ = fooproto;

I would like

console.log("foo2=", foo2);

to show something like foo2=Foo#37[Foo#11] on the console (if possible with the italics)

Is there a way to change fooproto to make that work? I guess that some mechanism exist, since console.log is displaying nicely DOM objects.

It is probably a FAQ asked many times, but I was not able after several minutes of searching to find the appropriate search keywords. I don't know what terminology to use

解决方案

I’m not developing for Firefox and apologies if you’ve already seen this, but I’ve stumbled across this:

Seems like something that might answer your needs.

这篇关于定制firefox console.log(为我自己的原型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆