var util = require("util");
var assert = require("assert");
var now = require("date-now");

var _console = {};
var times = {};

var functions = [
	['log','info'],
	['info','info'],
	['warn','warn'],
	['error','error']
];

functions.forEach(function(tuple) {
	_console[tuple[0]] = function() {
		Ti.API[tuple[1]](util.format.apply(util, arguments));
	};
});

_console.time = function(label) {
	times[label] = now();
};

_console.timeEnd = function(label) {
	var time = times[label];
	if (!time) {
		throw new Error("No such label: " + label);
	}

	var duration = now() - time;
	console.log(label + ": " + duration + "ms");
};

_console.trace = function() {
	var err = new Error();
	err.name = "Trace";
	err.message = util.format.apply(null, arguments);
	console.error(err.stack);
};

_console.dir = function(object) {
	console.log(util.inspect(object) + "\n");
};

_console.assert = function(expression) {
	if (!expression) {
		var arr = Array.prototype.slice.call(arguments, 1);
		assert.ok(false, util.format.apply(null, arr));
	}
};

module.exports = _console;

@@ -570,16 +570,17 @@
  time;%0A%09
+_
 console.
@@ -747,16 +747,17 @@
 ents);%0A%09
+_
 console.
@@ -813,16 +813,17 @@
 ect) %7B%0A%09
+_
 console.

Use `_console` instead of `console`