words

Custom console.log w/ timestamps

window.log = function(){
	var now = new Date();
	var timestamp = now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();

	log.history = log.history || [];   // store logs to an array for reference
	log.history.push(arguments);
	if(this.console){
		console.log(timestamp.toString(), Array.prototype.slice.call(arguments) );
	}else{
		alert( timestamp.toString()+Array.prototype.slice.call(arguments) );
	}
};

// Example
...
mixes : function (sort,tag) {
	log('Router selected route: mixes',sort,tag);
	...


console-log

hint: I’m using alert at smartTV Emulator for logging.

inspiration: http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/

Last updated: