@formatjs/ts-transformer
Version:
TS Compiler transformer for formatjs
25 lines (24 loc) • 693 B
JavaScript
import { format, styleText } from "node:util";
const LEVEL_COLORS = {
debug: "green",
warn: "yellow",
error: "red"
};
function label(level, message) {
return `[@formatjs/ts-transformer] [${styleText(LEVEL_COLORS[level], level.toUpperCase())}] ${message}`;
}
export async function debug(message, ...args) {
if (process.env.LOG_LEVEL !== "debug") {
return;
}
console.error(format(label("debug", message), ...args));
console.error("\n");
}
export function warn(message, ...args) {
console.error(format(label("warn", message), ...args));
console.error("\n");
}
export function error(message, ...args) {
console.error(format(label("error", message), ...args));
console.error("\n");
}