forked from mirrors/Scribe.js
Adding inspector args
This commit is contained in:
parent
c6d5ad61df
commit
d40ba177a6
5 changed files with 55 additions and 25 deletions
10
deps.json
10
deps.json
|
@ -166,7 +166,7 @@
|
||||||
"material": "material",
|
"material": "material",
|
||||||
"licenseType": "LGPLv3",
|
"licenseType": "LGPLv3",
|
||||||
"link": "git+https://github.com/mWater/minimongo.git",
|
"link": "git+https://github.com/mWater/minimongo.git",
|
||||||
"comment": "3.6.1"
|
"comment": "3.7.2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"department": "kessler",
|
"department": "kessler",
|
||||||
|
@ -196,7 +196,7 @@
|
||||||
"material": "material",
|
"material": "material",
|
||||||
"licenseType": "Artistic-2.0",
|
"licenseType": "Artistic-2.0",
|
||||||
"link": "git+https://github.com/npm/npm.git",
|
"link": "git+https://github.com/npm/npm.git",
|
||||||
"comment": "3.6.0"
|
"comment": "3.7.0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"department": "kessler",
|
"department": "kessler",
|
||||||
|
@ -276,7 +276,7 @@
|
||||||
"material": "material",
|
"material": "material",
|
||||||
"licenseType": "ISC",
|
"licenseType": "ISC",
|
||||||
"link": "git+https://github.com/bluejamesbond/Influx.js.git",
|
"link": "git+https://github.com/bluejamesbond/Influx.js.git",
|
||||||
"comment": "1.0.7"
|
"comment": "1.0.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"department": "kessler",
|
"department": "kessler",
|
||||||
|
@ -326,7 +326,7 @@
|
||||||
"material": "material",
|
"material": "material",
|
||||||
"licenseType": "MIT",
|
"licenseType": "MIT",
|
||||||
"link": "git://github.com/Automattic/socket.io",
|
"link": "git://github.com/Automattic/socket.io",
|
||||||
"comment": "1.4.4"
|
"comment": "1.4.5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"department": "kessler",
|
"department": "kessler",
|
||||||
|
@ -346,7 +346,7 @@
|
||||||
"material": "material",
|
"material": "material",
|
||||||
"licenseType": "MIT",
|
"licenseType": "MIT",
|
||||||
"link": "git://github.com/visionmedia/superagent.git",
|
"link": "git://github.com/visionmedia/superagent.git",
|
||||||
"comment": "1.7.1"
|
"comment": "1.7.2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"department": "kessler",
|
"department": "kessler",
|
||||||
|
|
14
dist/scribe.js
vendored
14
dist/scribe.js
vendored
|
@ -44,14 +44,14 @@ exports.default = function () {
|
||||||
|
|
||||||
console.pipe.apply(console, args);
|
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()]);
|
var args = appendTransforms(['express', 'mongo-socket', new _ErrorExtractor2.default(), new _ExpressExtractor2.default()]);
|
||||||
|
|
||||||
console.pipe.apply(console, args);
|
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);
|
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/',
|
basePath: 'scribe/',
|
||||||
socketPort: 4000,
|
socketPort: 4000,
|
||||||
socket: true,
|
socket: true,
|
||||||
|
inspector: {
|
||||||
|
colors: true,
|
||||||
|
showHidden: false,
|
||||||
|
depth: 5,
|
||||||
|
pre: true,
|
||||||
|
callsite: true,
|
||||||
|
tags: true,
|
||||||
|
args: true,
|
||||||
|
metrics: true
|
||||||
|
},
|
||||||
web: {
|
web: {
|
||||||
router: {
|
router: {
|
||||||
username: 'build',
|
username: 'build',
|
||||||
|
|
23
dist/transforms/Inspector.js
vendored
23
dist/transforms/Inspector.js
vendored
|
@ -34,9 +34,14 @@ var _inspect2 = _interopRequireDefault(_inspect);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
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 () {
|
var Inspector = function () {
|
||||||
function Inspector() {
|
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);
|
(0, _classCallCheck3.default)(this, Inspector);
|
||||||
|
|
||||||
this.inspectOpts = inspectOpts;
|
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) {
|
for (var _iterator = (0, _getIterator3.default)([f].concat(args)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||||
var arg = _step.value;
|
var arg = _step.value;
|
||||||
|
|
||||||
objects.push((0, _inspect2.default)(arg, ctx));
|
objects.push(inspect(arg, ctx));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
_didIteratorError = true;
|
_didIteratorError = true;
|
||||||
|
@ -95,12 +100,12 @@ var Inspector = function () {
|
||||||
case '%s':
|
case '%s':
|
||||||
case '%d':
|
case '%d':
|
||||||
case '%j':
|
case '%j':
|
||||||
return (0, _inspect2.default)(args[i++], ctx);
|
return inspect(args[i++], ctx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var x = args[i]; i < len; x = args[++i]) {
|
for (var x = args[i]; i < len; x = args[++i]) {
|
||||||
str += ' ' + (0, _inspect2.default)(x, ctx);
|
str += ' ' + inspect(x, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
@ -151,11 +156,11 @@ var Inspector = function () {
|
||||||
data.args = '';
|
data.args = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
var pre = this.inspectPre(data);
|
var pre = this.inspectOpts.pre ? this.inspectPre(data) + ' ' : '';
|
||||||
var tags = this.inspectTags(data);
|
var tags = this.inspectOpts.tags ? this.inspectTags(data) : '';
|
||||||
var metrics = this.inspectMetrics(data);
|
var metrics = this.inspectOpts.metrics ? this.inspectMetrics(data) : '';
|
||||||
var site = this.inspectCallSite(data);
|
var site = this.inspectOpts.callsite ? this.inspectCallSite(data) : '';
|
||||||
var pretty = this.inspectArguments(data);
|
var pretty = this.inspectOpts.args ? this.inspectArguments(data) : '';
|
||||||
var inspected = pretty.split('\n').map(function (line) {
|
var inspected = pretty.split('\n').map(function (line) {
|
||||||
return pre + ' ' + [tags, metrics, line, site].join(' ');
|
return pre + ' ' + [tags, metrics, line, site].join(' ');
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,6 +27,16 @@ const defaultOpts = {
|
||||||
basePath: 'scribe/',
|
basePath: 'scribe/',
|
||||||
socketPort: 4000,
|
socketPort: 4000,
|
||||||
socket: true,
|
socket: true,
|
||||||
|
inspector: {
|
||||||
|
colors: true,
|
||||||
|
showHidden: false,
|
||||||
|
depth: 5,
|
||||||
|
pre: true,
|
||||||
|
callsite: true,
|
||||||
|
tags: true,
|
||||||
|
args: true,
|
||||||
|
metrics: true
|
||||||
|
},
|
||||||
web: {
|
web: {
|
||||||
router: {
|
router: {
|
||||||
username: 'build',
|
username: 'build',
|
||||||
|
@ -82,7 +92,7 @@ export default function (id = process.pid, opts = rc('scribe', defaultOpts), ...
|
||||||
console.pipe.apply(console, args);
|
console.pipe.apply(console, args);
|
||||||
|
|
||||||
console.pipe(expose, 'bash',
|
console.pipe(expose, 'bash',
|
||||||
new Inspector(),
|
new Inspector(opts.inspector),
|
||||||
new DefaultConsole());
|
new DefaultConsole());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,7 +103,7 @@ export default function (id = process.pid, opts = rc('scribe', defaultOpts), ...
|
||||||
console.pipe('express', 'bash',
|
console.pipe('express', 'bash',
|
||||||
new ExpressExtractor(),
|
new ExpressExtractor(),
|
||||||
new ExpressInspector(),
|
new ExpressInspector(),
|
||||||
new Inspector(),
|
new Inspector(opts.inspector),
|
||||||
new DefaultConsole());
|
new DefaultConsole());
|
||||||
|
|
||||||
console.viewer = create.bind(null, opts.mongo && opts.mongoUri, opts.web.router, opts.web.client, opts.debug);
|
console.viewer = create.bind(null, opts.mongo && opts.mongoUri, opts.web.router, opts.web.client, opts.debug);
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import _ from 'underscore'
|
import _ from 'underscore'
|
||||||
import chalk from 'chalk'
|
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 {
|
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;
|
this.inspectOpts = inspectOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,11 +78,11 @@ export default class Inspector {
|
||||||
data.args = '';
|
data.args = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const pre = this.inspectPre(data);
|
const pre = this.inspectOpts.pre ? `${this.inspectPre(data)} ` : '';
|
||||||
const tags = this.inspectTags(data);
|
const tags = this.inspectOpts.tags ? this.inspectTags(data) : '';
|
||||||
const metrics = this.inspectMetrics(data);
|
const metrics = this.inspectOpts.metrics ? this.inspectMetrics(data) : '';
|
||||||
const site = this.inspectCallSite(data);
|
const site = this.inspectOpts.callsite ? this.inspectCallSite(data) : '';
|
||||||
const pretty = this.inspectArguments(data);
|
const pretty = this.inspectOpts.args ? this.inspectArguments(data) : '';
|
||||||
const inspected = pretty.split('\n').map(line =>`${pre} ${[tags, metrics, line, site].join(' ')}`);
|
const inspected = pretty.split('\n').map(line =>`${pre} ${[tags, metrics, line, site].join(' ')}`);
|
||||||
|
|
||||||
data.inspected = inspected;
|
data.inspected = inspected;
|
||||||
|
|
Loading…
Add table
Reference in a new issue