1

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

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547

1 Answers1

1

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.

Anton Strogonoff
  • 32,294
  • 8
  • 53
  • 61
  • On second thought console API may not answer your need fully since it has only limited formatting capabilities. However, custom output seems to be pretty flexible if you’re willing to dive in—it’s among the docs intended for plugin developers, I think – Anton Strogonoff Nov 06 '15 at 13:18