UNPKG

bundlewatch

Version:
62 lines (50 loc) 1.39 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const stdout = console.log; // eslint-disable-line no-console const stderr = console.error; // eslint-disable-line no-console const debug = error => { if (process.env.DEBUG) { const debugObject = error.response ? error.response.data : error.response; stdout(_chalk2.default.greenBright(`[DEBUG] ${error.message}`)); stderr(error); try { stderr(JSON.stringify(debugObject, undefined, 2)); } catch (e) { // eat it } } }; const log = message => { stdout(message); }; const info = message => { stdout(_chalk2.default.cyan(`[INFO] ${message}`)); }; const warn = message => { stdout(_chalk2.default.yellow(`[WARNING] ${message}`)); }; const error = (messsage, errorStack) => { if (errorStack) { stdout(errorStack); } stderr(_chalk2.default.red(`[ERROR] ${messsage}`)); }; const fatal = (messsage, errorStack) => { if (errorStack) { stdout(errorStack); } stderr(_chalk2.default.black.bgRed(`[FATAL] ${messsage}`)); }; exports.default = { debug, log, info, warn, error, fatal };