mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2024-12-21 03:09:14 +08:00
24 lines
941 B
TypeScript
24 lines
941 B
TypeScript
import chalk from "chalk";
|
|
|
|
export enum LogStyle {
|
|
None = "None",
|
|
Info = "Info",
|
|
Warning = "Warning",
|
|
Failure = "Failure",
|
|
Success = "Success"
|
|
}
|
|
|
|
const LogStyleDetails: {[style: string]: {style: chalk.Chalk, prefix: string}} = {};
|
|
LogStyleDetails[LogStyle.Info] = {style: chalk.white, prefix: chalk.white.inverse("INFO")};
|
|
LogStyleDetails[LogStyle.Warning] = {style: chalk.yellow, prefix: chalk.yellow.inverse("WARN")};
|
|
LogStyleDetails[LogStyle.Failure] = {style: chalk.red, prefix: chalk.red.inverse("UHOH")};
|
|
LogStyleDetails[LogStyle.Success] = {style: chalk.green, prefix: chalk.green.inverse(" OK ")};
|
|
|
|
export function log(style: LogStyle, message: string) {
|
|
if (style === LogStyle.None) {
|
|
console.log(chalk.whiteBright(message));
|
|
} else {
|
|
const details: {style: chalk.Chalk, prefix: string} = LogStyleDetails[style];
|
|
console.log(details.prefix + " " + details.style(message));
|
|
}
|
|
} |