Well, my first search revealed little useful information, with most
people hacking together solutions. With a bit more diligence, I came
across a solution for IE7 called Companion.JS, and it seems for IE8 the
console is built in. Safari 4 is OK, Safari 3 almost works, could not
figure out how to see the warn and error messages! The only browser that
I need to support that does not have a window.console is Opera, but it
has a "window.opera.postError" that could be used.

If anyone knows what I'm missing for Safari 3 or Opera, let me know,
else I'll work on a small patch to log.js.

For the future I added a FAQ entry:
http://cwiki.apache.org/confluence/display/SHINDIG/Index#Index-Howtoacce
sstheconsoleforgadgets.log%3F


-----Original Message-----
From: Tim Wintle [mailto:[email protected]] 
Sent: Tuesday, September 29, 2009 1:41 AM
To: [email protected]
Subject: Re: gadgets.log for all browsers?

On Fri, 2009-09-25 at 12:52 -0600, Weygandt, Jon wrote:
> gadgets.log, it's part of the mandatory core API, but yet Shindigs 
> implementation only works for browsers with a window.console
<snip>
> After doing some googling I discovered that most people advocate 
> creating a <div> and placing messages in the div. Seems a workable 
> idea, plus we could call adjustHeight after doing so. The one question

> is what should we use to make the <div> visible for debugging
purposes?
>  
> One idea is to capture some obscure keystroke or mouse click event on 
> document.body to make the div visible.

The old javascript/container/gadgets.js used to log messages in that
way:

gadgets.log = function(message) {
  if (window.console && console.log) {
    console.log(message);
  } else {
    var logEntry = document.createElement('div');
    logEntry.className = 'gadgets-log-entry';
    logEntry.innerHTML = message;
    document.body.appendChild(logEntry);
  }
};

How about appending the elements to a span with style set to
"display:none" (rather than to the body as above), so that while
debugging you can make the entire log visible by a style change?


Tim W


Reply via email to