customizing firefox console.log (for my own protot

2019-08-11 19:24发布

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

1条回答
相关推荐>>
2楼-- · 2019-08-11 19:56

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.

查看更多
登录 后发表回答