UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

51 lines (48 loc) 1.61 kB
import { init_esm_shims, __name } from './chunk-QH7NXH7H.js'; import { getLogFn, getLogLevel } from '@storm-software/config-tools/logger'; import { LogLevelLabel } from '@storm-software/config-tools/types'; import { getColor } from '@storm-software/config-tools/utilities/colors'; import { noop } from '@stryke/helpers/noop'; import { titleCase } from '@stryke/string-format/title-case'; import chalk from 'chalk'; // src/lib/logger.ts init_esm_shims(); var createLog = /* @__PURE__ */ __name((name, options = {}) => { const logLevel = options.logLevel || LogLevelLabel.INFO; if (logLevel === LogLevelLabel.SILENT) { return noop; } if (options.customLogger) { return options.customLogger; } return (type, ...args) => getLogFn(getLogLevel(type), { ...options, logLevel })(`${chalk.bold.hex(getColor("brand", options))(`storm-stack${name ? `:${name}` : ""} ${chalk.gray("> ")}`)}${args.join(" ")} `.trim()); }, "createLog"); var BADGE_COLORS = [ "#00A0DD", "#6FCE4E", "#FBBF24", "#F43F5E", "#3B82F6", "#A855F7", "#469592", "#288EDF", "#10B981", "#EF4444", "#F0EC56", "#F472B6", "#22D3EE", "#EAB308", "#84CC16", "#F87171", "#0EA5E9", "#D946EF", "#FACC15", "#34D399" ]; var extendLog = /* @__PURE__ */ __name((logFn, name) => { return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `); }, "extendLog"); export { createLog, extendLog };