UNPKG

log-it-colored

Version:

Miniature ready-to-use console logger that just writes in a given color

53 lines 1.98 kB
import chalk from "chalk"; import { string_format } from "./utils/string-format.js"; export class LogItColored { blue = (...content) => { return console.info(chalk.blueBright(string_format(...content))); }; violet = (...content) => { return console.info(chalk.rgb(255, 0, 242)(string_format(...content))); }; slate = (...content) => { return console.info(chalk.rgb(179, 179, 179)(string_format(...content))); }; red = (...content) => { return console.error(chalk.rgb(255, 0, 0)(string_format(...content))); }; /** Raw error output (no coloring) */ error = (...content) => { return console.error(...content); }; /** Success uses info (colored green) */ success = (...content) => { return console.info(chalk.green(string_format(...content))); }; sky = (...content) => { return console.info(chalk.rgb(94, 242, 255)(string_format(...content))); }; green = (...content) => { return console.info(chalk.rgb(0, 255, 34)(string_format(...content))); }; yellow = (...content) => { return console.info(chalk.rgb(218, 207, 0)(string_format(...content))); }; gray = (...content) => { return console.info(chalk.rgb(122, 122, 122)(string_format(...content))); }; /** Plain output without coloring */ raw = (...content) => { return console.info(...content); }; /** Convenience alias */ log = (...content) => { return this.raw(...content); }; /** Small helper: prints a table when applicable */ table = (tabularData) => { // prefer console.table for arrays/objects; fallback to formatted log if (Array.isArray(tabularData) || (tabularData && typeof tabularData === "object")) { return console.table(tabularData); } return this.raw(tabularData); }; } //# sourceMappingURL=logger.js.map