// This is a helper to take object data and break it into rows add(data, {joiner = this.joiner, sort = this.sort} = {}) { _.forEach(sort ? _.sortBy(_.keys(data)) : _.keys(data), key => { // Do some special things for arrays if (_.isArray(data[key])) data[key] = data[key].join(joiner); // Do something special for objects if (_.isObject(data[key])) data[key] = util.inspect(data[key], {compact: true}); // Do the normal push this.push([(chalk[this.keyColor](_.toUpper(key))), data[key]]); }); }
/* istanbul ignore next */ [util.inspect.custom](depth, options) { // https://nodejs.org/docs/latest-v8.x/api/util.html#util_custom_inspection_functions_on_objects if (depth < 0) { return options.stylize("[Context]", "special"); } const inner = util.inspect(this.toJSON(), options); return `${options.stylize("Context", "special")}< ${inner} >`; }
Object.keys(labels).forEach(label => { if (savedLabels.indexOf(label) === -1) { throw new Error( `Added label "${label}" is not included in initial labelset: ${util.inspect( savedLabels, )}`, ); } });
"$metrics.state"(payload) { this.broker.logger.info("Metrics event received! Size:", payload.length); this.broker.logger.info(util.inspect(payload, { depth: 4, colors: true })); }
/** * Initialize logger. * * @param {LoggerFactory} loggerFactory */ init(loggerFactory) { super.init(loggerFactory); this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : o => util.inspect(o, { showHidden: false, depth: 2, colors: false, breakLength: Number.POSITIVE_INFINITY }); if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval); this.timer.unref(); } }
this.update(util.inspect(data)) this.screen.render()
init(loggerFactory) { super.init(loggerFactory); if (!this.opts.colors) kleur.enabled = false; this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : o => util.inspect(o, { showHidden: false, depth: 2, colors: kleur.enabled, breakLength: Number.POSITIVE_INFINITY }); // Generate colorful log level names this.levelColorStr = BaseLogger.LEVELS.reduce((a, level) => { a[level] = getColor(level)(_.padEnd(level.toUpperCase(), 5)); return a; }, {}); if (this.opts.colors && this.opts.moduleColors === true) { this.opts.moduleColors = [ "yellow", "bold.yellow", "cyan", "bold.cyan", "green", "bold.green", "magenta", "bold.magenta", "blue", "bold.blue", /*"red",*/ /*"grey",*/ /*"white,"*/ ]; } }
console.log(_args.map(function (v, k) { var __str, __owner = v, __inspect = __owner && __owner.inspect; if (__inspect) { while (1) { if (__owner == null || __owner.hasOwnProperty('inspect')) break; __owner = __owner.__proto__; } __owner.inspect = null; } __str = util.inspect(v, { showHidden: true, colors: true, depth: null }); if (__inspect) __owner.inspect = __inspect; return __str; }).join(' '));
function runScript(handle: HandleType, _agent: MonitorAgent | MasterAgent, app: Application, comd: string, context: string , param: string , cb: (err?: Error | string , data?: any) => void) { if (handle === 'client') { let agent = _agent as MasterAgent; if (context === 'all') { cb('context error'); return; } agent.request(context, WatchServerModule.moduleId, { comd: comd, param: param, context: context }, function (err, msg) { cb(null, msg); }); } else if (handle === 'monitor') { let agent = _agent as MonitorAgent; let ctx = { app: app, result: null as any }; try { vm.createContext(ctx); vm.runInNewContext('result = ' + param, ctx); cb(null, util.inspect(ctx.result)); } catch (e) { cb(null, e.stack); } } }
/** * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid. * @param {options} options The given options for the rule. * @returns {number|string} The rule's severity value */ function validateRuleSeverity(options) { const severity = Array.isArray(options) ? options[0] : options; if (severity !== 0 && severity !== 1 && severity !== 2 && !(typeof severity === "string" && /^(?:off|warn|error)$/i.test(severity))) { throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/g, "\"").replace(/\n/g, "")}').\n`); } return severity; }
truthyValues.forEach(function (val) { test('should be enabled by environment variable ELASTIC_APM_ACTIVE set to: ' + util.inspect(val), function (t) { var agent = Agent() process.env.ELASTIC_APM_ACTIVE = val agent.start({ serviceName: 'foo', secretToken: 'baz' }) t.strictEqual(agent._conf.active, true) delete process.env.ELASTIC_APM_ACTIVE t.end() }) })
formatJSON ({ [ERROR_SYMBOL]: error, ...meta }) { delete meta._level; if (error) { if ([GABError, GABTypeError, GABRangeError].includes(error.constructor)) { if (error._meta) Object.assign(meta, error._meta); delete error._meta; } meta.error = inspect(error, { breakLength: Infinity, depth: 1 }); } return meta; }
falsyValues.forEach(function (val) { test('should be disabled by environment variable ELASTIC_APM_ACTIVE set to: ' + util.inspect(val), function (t) { var agent = Agent() process.env.ELASTIC_APM_ACTIVE = val agent.start({ serviceName: 'foo', secretToken: 'baz' }) t.strictEqual(agent._conf.active, false) delete process.env.ELASTIC_APM_ACTIVE t.end() }) })