UNPKG

@primer/primitives

Version:

Typography, spacing, and color primitives for Primer design system

35 lines (34 loc) 1.65 kB
const logMessage = (message, type = 'warning', config) => { var _a, _b, _c, _d, _e; // early return if verbosity is silent if (((_a = config === null || config === void 0 ? void 0 : config.log) === null || _a === void 0 ? void 0 : _a.verbosity) === 'silent' && type !== 'error') { return; } // early return if verbosity is default and type is info if (((_b = config === null || config === void 0 ? void 0 : config.log) === null || _b === void 0 ? void 0 : _b.verbosity) === 'default' && type === 'info') { return; } // early return if ((((_c = config === null || config === void 0 ? void 0 : config.log) === null || _c === void 0 ? void 0 : _c.warnings) === 'disabled' || ((_d = config === null || config === void 0 ? void 0 : config.log) === null || _d === void 0 ? void 0 : _d.warnings) === 'warn') && type === 'info') { return; } // early return if (((_e = config === null || config === void 0 ? void 0 : config.log) === null || _e === void 0 ? void 0 : _e.warnings) === 'disabled' && type === 'warning') { return; } if (type === 'warning') { // eslint-disable-next-line no-console return console.warn(message); } if (type === 'error') { // eslint-disable-next-line no-console return console.error(message); } // eslint-disable-next-line no-console console.log(message); }; export const log = { info: (message, config) => logMessage(message, 'info', config), warning: (message, config) => logMessage(message, 'warning', config), error: (message, config) => logMessage(message, 'error', config), };