yumechi-no-kuni/src/utils/logger.ts
Aya Morisawa cf446ac53c Implement logger
log-cool is no longer with Misskey
2016-12-29 17:36:03 +09:00

16 lines
434 B
TypeScript

import * as chalk from 'chalk';
export type LogLevel = 'Error' | 'Warn' | 'Info';
function toLevelColor(level: LogLevel): chalk.ChalkStyle {
switch (level) {
case 'Error': return chalk.red;
case 'Warn': return chalk.yellow;
case 'Info': return chalk.blue;
}
}
export function log(level: LogLevel, message: string): void {
let color = toLevelColor(level);
console.log(`[${color.bold(level.toUpperCase())}] ${message}`);
}