Adding inspector args

This commit is contained in:
Mathew Kurian 2016-01-29 01:31:33 -06:00
parent c6d5ad61df
commit d40ba177a6
5 changed files with 55 additions and 25 deletions

View file

@ -166,7 +166,7 @@
"material": "material",
"licenseType": "LGPLv3",
"link": "git+https://github.com/mWater/minimongo.git",
"comment": "3.6.1"
"comment": "3.7.2"
},
{
"department": "kessler",
@ -196,7 +196,7 @@
"material": "material",
"licenseType": "Artistic-2.0",
"link": "git+https://github.com/npm/npm.git",
"comment": "3.6.0"
"comment": "3.7.0"
},
{
"department": "kessler",
@ -276,7 +276,7 @@
"material": "material",
"licenseType": "ISC",
"link": "git+https://github.com/bluejamesbond/Influx.js.git",
"comment": "1.0.7"
"comment": "1.0.8"
},
{
"department": "kessler",
@ -326,7 +326,7 @@
"material": "material",
"licenseType": "MIT",
"link": "git://github.com/Automattic/socket.io",
"comment": "1.4.4"
"comment": "1.4.5"
},
{
"department": "kessler",
@ -346,7 +346,7 @@
"material": "material",
"licenseType": "MIT",
"link": "git://github.com/visionmedia/superagent.git",
"comment": "1.7.1"
"comment": "1.7.2"
},
{
"department": "kessler",

14
dist/scribe.js vendored
View file

@ -44,14 +44,14 @@ exports.default = function () {
console.pipe.apply(console, args);
console.pipe(expose, 'bash', new _Inspector2.default(), new _DefaultConsole2.default());
console.pipe(expose, 'bash', new _Inspector2.default(opts.inspector), new _DefaultConsole2.default());
});
var args = appendTransforms(['express', 'mongo-socket', new _ErrorExtractor2.default(), new _ExpressExtractor2.default()]);
console.pipe.apply(console, args);
console.pipe('express', 'bash', new _ExpressExtractor2.default(), new _ExpressInspector2.default(), new _Inspector2.default(), new _DefaultConsole2.default());
console.pipe('express', 'bash', new _ExpressExtractor2.default(), new _ExpressInspector2.default(), new _Inspector2.default(opts.inspector), new _DefaultConsole2.default());
console.viewer = _viewer.create.bind(null, opts.mongo && opts.mongoUri, opts.web.router, opts.web.client, opts.debug);
@ -167,6 +167,16 @@ var defaultOpts = {
basePath: 'scribe/',
socketPort: 4000,
socket: true,
inspector: {
colors: true,
showHidden: false,
depth: 5,
pre: true,
callsite: true,
tags: true,
args: true,
metrics: true
},
web: {
router: {
username: 'build',

View file

@ -34,9 +34,14 @@ var _inspect2 = _interopRequireDefault(_inspect);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function inspect(x, ctx) {
return typeof x === 'string' ? x : (0, _inspect2.default)(x, ctx);
}
var Inspector = function () {
function Inspector() {
var inspectOpts = arguments.length <= 0 || arguments[0] === undefined ? { colors: true, showHidden: false, depth: 5 } : arguments[0];
var inspectOpts = arguments.length <= 0 || arguments[0] === undefined ? { colors: true, showHidden: false,
depth: 5, pre: true, args: true, metrics: true, tags: true } : arguments[0];
(0, _classCallCheck3.default)(this, Inspector);
this.inspectOpts = inspectOpts;
@ -61,7 +66,7 @@ var Inspector = function () {
for (var _iterator = (0, _getIterator3.default)([f].concat(args)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var arg = _step.value;
objects.push((0, _inspect2.default)(arg, ctx));
objects.push(inspect(arg, ctx));
}
} catch (err) {
_didIteratorError = true;
@ -95,12 +100,12 @@ var Inspector = function () {
case '%s':
case '%d':
case '%j':
return (0, _inspect2.default)(args[i++], ctx);
return inspect(args[i++], ctx);
}
});
for (var x = args[i]; i < len; x = args[++i]) {
str += ' ' + (0, _inspect2.default)(x, ctx);
str += ' ' + inspect(x, ctx);
}
return str;
@ -151,11 +156,11 @@ var Inspector = function () {
data.args = '';
}
var pre = this.inspectPre(data);
var tags = this.inspectTags(data);
var metrics = this.inspectMetrics(data);
var site = this.inspectCallSite(data);
var pretty = this.inspectArguments(data);
var pre = this.inspectOpts.pre ? this.inspectPre(data) + ' ' : '';
var tags = this.inspectOpts.tags ? this.inspectTags(data) : '';
var metrics = this.inspectOpts.metrics ? this.inspectMetrics(data) : '';
var site = this.inspectOpts.callsite ? this.inspectCallSite(data) : '';
var pretty = this.inspectOpts.args ? this.inspectArguments(data) : '';
var inspected = pretty.split('\n').map(function (line) {
return pre + ' ' + [tags, metrics, line, site].join(' ');
});

View file

@ -27,6 +27,16 @@ const defaultOpts = {
basePath: 'scribe/',
socketPort: 4000,
socket: true,
inspector: {
colors: true,
showHidden: false,
depth: 5,
pre: true,
callsite: true,
tags: true,
args: true,
metrics: true
},
web: {
router: {
username: 'build',
@ -82,7 +92,7 @@ export default function (id = process.pid, opts = rc('scribe', defaultOpts), ...
console.pipe.apply(console, args);
console.pipe(expose, 'bash',
new Inspector(),
new Inspector(opts.inspector),
new DefaultConsole());
});
@ -93,7 +103,7 @@ export default function (id = process.pid, opts = rc('scribe', defaultOpts), ...
console.pipe('express', 'bash',
new ExpressExtractor(),
new ExpressInspector(),
new Inspector(),
new Inspector(opts.inspector),
new DefaultConsole());
console.viewer = create.bind(null, opts.mongo && opts.mongoUri, opts.web.router, opts.web.client, opts.debug);

View file

@ -1,9 +1,14 @@
import _ from 'underscore'
import chalk from 'chalk'
import inspect from '../libs/inspect'
import inspector from '../libs/inspect'
function inspect(x, ctx) {
return typeof x === 'string' ? x : inspector(x, ctx);
}
export default class Inspector {
constructor(inspectOpts = {colors: true, showHidden: false, depth: 5}) {
constructor(inspectOpts = {colors: true, showHidden: false,
depth: 5, pre: true, args: true, metrics: true, tags: true}) {
this.inspectOpts = inspectOpts;
}
@ -73,11 +78,11 @@ export default class Inspector {
data.args = '';
}
const pre = this.inspectPre(data);
const tags = this.inspectTags(data);
const metrics = this.inspectMetrics(data);
const site = this.inspectCallSite(data);
const pretty = this.inspectArguments(data);
const pre = this.inspectOpts.pre ? `${this.inspectPre(data)} ` : '';
const tags = this.inspectOpts.tags ? this.inspectTags(data) : '';
const metrics = this.inspectOpts.metrics ? this.inspectMetrics(data) : '';
const site = this.inspectOpts.callsite ? this.inspectCallSite(data) : '';
const pretty = this.inspectOpts.args ? this.inspectArguments(data) : '';
const inspected = pretty.split('\n').map(line =>`${pre} ${[tags, metrics, line, site].join(' ')}`);
data.inspected = inspected;