Simple script to import 'console' namespace methods ... I.E. log(this) for console.log(this), dir(this) for console.dir(this)
(function() {
this.assert = assert;
this.clear = clear;
this.confirm = confirm;
this.count = count;
this.debug = debug;
this.dir = dir;
this.dirxml = dirxml;
this.error = error;
this.group = group;
this.groupCollapsed = groupCollapsed;
this.groupEnd = groupEnd;
this.info = info;
this.log = log;
this.markTimeline = markTimeline;
this.profile = profile;
this.profileEnd = profileEnd;
this.table = table;
this.time = time;
this.timeEnd = timeEnd;
this.timeStamp = timeStamp;
this.timeline = timeline;
this.timelineEnd = timelineEnd;
this.trace = trace;
this.warn = warn;
function getConsole( type ) {
switch( type ) {
case assert :
return console.assert;
break;
case clear :
return console.clear;
break;
case confirm :
return console.confirm;
break;
case count :
return console.count;
break;
case debug :
return console.debug;
break;
case dir :
return console.dir;
break;
case dirxml :
return console.dirxml;
break;
case error :
return console.error;
break;
case group :
return console.group;
break;
case groupCollapsed :
return console.groupCollapsed;
break;
case groupEnd :
return console.groupEnd;
break;
case info :
return console.info;
break;
case log :
return console.log;
break;
case markTimeline :
return console.markTimeline;
break;
case profile:
return console.profile;
break;
case profileEnd:
return console.profileEnd;
break;
case table:
return console.table;
break;
case time:
return console.time;
break;
case timeEnd:
return console.timeEnd;
break;
case timeStamp:
return console.timeStamp;
break;
case timeline:
return console.timeline;
break;
case timelineEnd:
return console.timelineEnd;
break;
case trace:
return console.trace;
break;
case warn:
return console.warn;
break;
default :
break;
}
}
function assert( val ) {
return getConsole( assert ).call( console, val );
}
function clear( val ) {
return getConsole( clear ).call( console, val );
}
function confirm( val ) {
return getConsole( confirm ).call( console, val );
}
function count( val ) {
return getConsole( count ).call( console, val );
}
function debug( val ) {
return getConsole( debug ).call( console, val );
}
function dir( val ) {
return getConsole( dir ).call( console, val );
}
function dirxml( val ) {
return getConsole( dirxml ).call( console, val );
}
function error( val ) {
return getConsole( error ).call( console, val );
}
function group( val ) {
return getConsole( group ).call( console, val );
}
function groupCollapsed( val ) {
return getConsole( groupCollapsed ).call( console, val );
}
function groupEnd( val ) {
return getConsole( groupEnd ).call( console, val );
}
function info( val ) {
return getConsole( info ).call( console, val );
}
function log( val ) {
return getConsole( log ).call( console, val );
}
function markTimeline( val ) {
return getConsole( markTimeline ).call( console, val );
}
function profile( val ) {
return getConsole( profile ).call( console, val );
}
function profileEnd( val ) {
return getConsole( profileEnd ).call( console, val );
}
function table( val ) {
return getConsole( table ).call( console, val );
}
function time( val ) {
return getConsole( time ).call( console, val );
}
function timeEnd( val ) {
return getConsole( timeEnd ).call( console, val );
}
function timeStamp( val ) {
return getConsole( timeStamp ).call( console, val );
}
function timeline( val ) {
return getConsole( timeline ).call( console, val );
}
function timelineEnd( val ) {
return getConsole( timelineEnd ).call( console, val );
}
function trace( val ) {
return getConsole( trace ).call( console, val );
}
function warn( val ) {
return getConsole( warn ).call( console, val );
}
return this;
})();