mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-24 04:59:06 +01:00
17 lines
434 B
TypeScript
17 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}`);
|
||
|
}
|