That would work, but there is a drawback in this approach too : what do we define exactly ? If we define console.log, maybe developers will expect console.warn to be defined as well, and start using it without checks. And maybe console.profile, next. The problem is there is no standard cross-browser API ( - or I could not find it), so it will be hard to draw the line of what we allow and what we don't. If we define our own API, then it's clear. Jerome. On Fri, Oct 29, 2010 at 5:54 PM, Denis Gervalle <[email protected]> wrote:
Why not simply defining console and console.log() when it is undefined ? This would avoid the need to think about using a specific wrapper. WDYT ?
Denis
On Fri, Oct 29, 2010 at 13:42, Marius Dumitru Florea < [email protected]> wrote:
On 10/29/2010 12:09 PM, Jerome Velociter wrote:
On Fri, Oct 29, 2010 at 10:02 AM, Marius Dumitru Florea <[email protected]> wrote:
+1, but out of curiosity..
On 10/28/2010 08:34 PM, Jerome Velociter wrote:
Hi devs,
I'd like to commit a console.log wrapper in xwiki.js that does some checking before logging, in the spirit of http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
Something like :
var XWiki = {
//snip
/** * console#log wrapper for your developer own convenience */ log: function(){ if(typeof console != "undefined"){
console.log( Array.prototype.slice.call(arguments) );
What's the point of Array.prototype.slice.call(arguments) ?
Apparently it's a trick to transform the "arguments" array-like object into an array. See
hhttps:// developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments
I wasn't aware of this. It's clear now.
I'm not sure what are the exact limitations of logging an array-like object versus a real array. In firebug, a visible difference is that you can expand the array as a whole (you have that little "+" on the left and then have all array properties and methods) , whereas with an array-like object you only see it's individual elements (that you can expand as well, individually), but can't expand the array.
Thanks, Marius
Jerome.
Thanks, Marius
} },
// snip
}
WDYT ?
Jerome _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Denis Gervalle SOFTEC sa - CEO eGuilde sarl - CTO _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs