Provides basic logging functionality for plugins to implement.
(function(global){
var log = function(){
if (global.console && console.log){
try {
console.log.apply(console, arguments);
} catch(e){
console.log(Array.slice(arguments));
}
} else {
Log.logged.push(arguments);
}
return this;
};
var disabled = function(){
this.logged.push(arguments);
return this;
};
this.Log = new Class({
logged: [],
log: disabled,
resetLog: function(){
this.logged.empty();
return this;
},
enableLog: function(){
this.log = log;
this.logged.each(function(args){
this.log.apply(this, args);
}, this);
return this.resetLog();
},
disableLog: function(){
this.log = disabled;
return this;
}
});
Log.extend(new Log).enableLog();
<1.2compat>
Log.logger = function(){
return this.log.apply(this, arguments);
};
</1.2compat>
})(this);