var Logger = {};

///// Log Types //////
Logger.Types = {
	debug: "debug",
	info: "info",
	success: "success",
	warning: "warning",
	error: "error"
};

Logger.enabled = true;
Logger.logAlert = false;

Logger.log = function (message, type) {
	if (!Logger.enabled)
		return;

	if (!type)
		type = Logger.Types.debug;
	
	var time = new Date().toLocaleTimeString();
	var formattedMessage = Logger.format(message, type, time);
	
	switch (type) {
	case Logger.Types.debug:
		console.debug(formattedMessage);
		break;

	case Logger.Types.info:
	case Logger.Types.success:
		console.info(formattedMessage);
		break;

	case Logger.Types.warning:
		alert(formattedMessage);
		console.warn(formattedMessage);
		break;

	case Logger.Types.error:
		console.error(formattedMessage);
		break;

	default:
		console.log(formattedMessage);
		break;
	}
	
	if (Logger.logAlert)
		alert(formattedMessage);
	
};


Logger.format = function (message, type, time) {
	if (!time)
		time = new Date().toLocaleTimeString();
	
	if (type && type != Logger.Types.debug)
		message = "[" + type + "] - " + message;
	
	message = "[" + time + "] " + message;
	return message;
};
