You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "Weygandt, Jon" <jw...@ebay.com> on 2009/09/25 20:52:57 UTC

gadgets.log for all browsers?

gadgets.log, it's part of the mandatory core API, but yet Shindigs
implementation only works for browsers with a window.console (I think
Firefox is the only browser). Having debugged many cross browser rpc
issues for our container authors, and seeing the new rpc implementation
making use of this, it is a welcome addition - if only it was available
cross browser.
 
Any thoughts on how to make it that way?
 
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.
 
Comments?
 

RE: gadgets.log for all browsers?

Posted by "Weygandt, Jon" <jw...@ebay.com>.
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:tim.wintle@teamrubber.com] 
Sent: Tuesday, September 29, 2009 1:41 AM
To: shindig-dev@incubator.apache.org
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



Re: gadgets.log for all browsers?

Posted by Tim Wintle <ti...@teamrubber.com>.
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