UNPKG

@knapsack/app

Version:

Build Design Systems on top of knapsack, by Basalt

101 lines (85 loc) 2.65 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.error = error; exports.info = info; exports.warn = warn; exports.verbose = verbose; exports.silly = silly; exports.inspect = inspect; exports.setLogLevel = setLogLevel; var _npmlog = _interopRequireDefault(require("npmlog")); var _util = _interopRequireDefault(require("util")); /** * Copyright (C) 2018 Basalt This file is part of Knapsack. Knapsack is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Knapsack is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Knapsack; if not, see <https://www.gnu.org/licenses>. */ // https://www.npmjs.com/package/npmlog function stringifyDeep(obj, depth = 5) { return _util.default.inspect(obj, { showHidden: false, depth }); } function error(msg, extra, prefix = '') { if (extra) { _npmlog.default.error(prefix, msg, stringifyDeep(extra)); } else { _npmlog.default.error(prefix, msg); } } function info(msg, extra, prefix = '') { if (extra) { _npmlog.default.info(prefix, msg, stringifyDeep(extra)); } else { _npmlog.default.info(prefix, msg); } } function warn(msg, extra, prefix = '') { if (extra) { _npmlog.default.warn(prefix, msg, stringifyDeep(extra)); } else { _npmlog.default.warn(prefix, msg); } } function verbose(msg, extra, prefix = '') { if (extra) { _npmlog.default.verbose(prefix, msg, stringifyDeep(extra)); } else { _npmlog.default.verbose(prefix, msg); } } function silly(msg, extra, prefix = '') { if (extra) { _npmlog.default.silly(prefix, msg, stringifyDeep(extra)); } else { _npmlog.default.silly(prefix, msg); } } /** * Log deeply nested object */ function inspect(obj, name = 'inspect', depth = 5) { console.log(); console.log(`Start: ${name} ================`); console.log(stringifyDeep(obj, depth)); console.log(`End: ${name} ----------------`); console.log(); } function setLogLevel(level) { // info(`Setting loglevel to ${level}`); _npmlog.default.level = level; } setLogLevel(process.env.KNAPSACK_LOG_LEVEL || 'info');