Implement logger

log-cool is no longer with Misskey
This commit is contained in:
Aya Morisawa
2016-12-29 17:36:03 +09:00
parent b87e6e8044
commit cf446ac53c
4 changed files with 32 additions and 17 deletions

16
src/utils/logger.ts Normal file
View File

@@ -0,0 +1,16 @@
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}`);
}