UNPKG

zcatalyst-cli

Version:

Command Line Tool for CATALYST

52 lines (51 loc) 2.15 kB
'use strict'; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.labeled = exports.error = exports.warning = exports.message = exports.success = exports.debug = exports.info = exports.log = void 0; const ansi_colors_1 = __importDefault(require("ansi-colors")); const char_1 = require("./char"); const winston_1 = __importDefault(require("../winston")); const util_1 = require("util"); function log(level, message, ...meta) { winston_1.default.log(level, message, meta); } exports.log = log; function info(msg = '', ...params) { winston_1.default.info((0, util_1.format)(msg, ...params)); } exports.info = info; function debug(msg = '', ...params) { winston_1.default.debug((0, util_1.format)(msg, ...params)); } exports.debug = debug; function success(msg, level = 'info', label = '') { const postChar = label === '' ? '' : label + ': '; winston_1.default.log(level, ansi_colors_1.default.green(char_1.CHAR.success + ' ' + postChar) + msg); } exports.success = success; function message(msg, level = 'info', label = '') { const postChar = label === '' ? '' : label + ': '; winston_1.default.log(level, ansi_colors_1.default.cyan(char_1.CHAR.info + ' ' + postChar) + msg); } exports.message = message; function warning(msg, level = 'warn', label = '') { const postChar = label === '' ? '' : label + ': '; winston_1.default.log(level, ansi_colors_1.default.yellow(char_1.CHAR.warning + ' ' + postChar) + msg); } exports.warning = warning; function error(msg, level = 'error', label = '') { const postChar = label === '' ? '' : label + ': '; winston_1.default.log(level, ansi_colors_1.default.red(char_1.CHAR.error + ' ' + postChar) + msg); } exports.error = error; function labeled(label, line) { return { SUCCESS: () => success(line, 'info', label), WARN: () => warning(line, 'warn', label), MESSAGE: () => message(line, 'info', label), ERROR: () => error(line, 'error', label) }; } exports.labeled = labeled;