enum LogLevel {
  INFO = 'INFO',
  ERROR = 'ERROR',
  WARN = 'WARN',
}

const Colors = {
	reset: '\x1b[0m',
	green: '\x1b[32m',
	red: '\x1b[31m',
	yellow: '\x1b[33m',
	cyan: '\x1b[36m'
};

class Logger {
	private getTime(): string {
		return new Date().toISOString();
	}

	private log(level: LogLevel, message: string): void {
		const time = this.getTime();

		let levelColor = '';
		switch(level) {
		case LogLevel.INFO:
			levelColor = Colors.green;
			break;
		case LogLevel.ERROR:
			levelColor = Colors.red;
			break;
		case LogLevel.WARN:
			levelColor = Colors.yellow;
			break;
		}

		console.log(`[${time}] ` + `${levelColor}${level}${Colors.reset} ` + `${Colors.cyan}${message}${Colors.reset}`);
	}

	public info(message: string): void {
		this.log(LogLevel.INFO, message);
	}

	public error(message: string): void {
		this.log(LogLevel.ERROR, message);
	}

	public warn(message: string): void {
		this.log(LogLevel.WARN, message);
	}
}

export { Logger };