parent
14c911de77
commit
539bf1d7b7
@ -85,12 +85,12 @@ Console.prototype.timeEnd = function(label) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Console.prototype.trace = function(label) {
|
Console.prototype.trace = function() {
|
||||||
// TODO probably can to do this better with V8's debug object once that is
|
// TODO probably can to do this better with V8's debug object once that is
|
||||||
// exposed.
|
// exposed.
|
||||||
var err = new Error;
|
var err = new Error;
|
||||||
err.name = 'Trace';
|
err.name = 'Trace';
|
||||||
err.message = label || '';
|
err.message = util.format.apply(this, arguments);
|
||||||
Error.captureStackTrace(err, arguments.callee);
|
Error.captureStackTrace(err, arguments.callee);
|
||||||
this.error(err.stack);
|
this.error(err.stack);
|
||||||
};
|
};
|
||||||
|
@ -43,13 +43,17 @@ console.log('foo', 'bar');
|
|||||||
console.log('%s %s', 'foo', 'bar', 'hop');
|
console.log('%s %s', 'foo', 'bar', 'hop');
|
||||||
console.log({slashes: '\\\\'});
|
console.log({slashes: '\\\\'});
|
||||||
|
|
||||||
|
console._stderr = process.stdout;
|
||||||
|
console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo');
|
||||||
|
|
||||||
global.process.stdout.write = stdout_write;
|
global.process.stdout.write = stdout_write;
|
||||||
|
|
||||||
assert.equal('foo\n', strings.shift());
|
assert.equal('foo\n', strings.shift());
|
||||||
assert.equal('foo bar\n', strings.shift());
|
assert.equal('foo bar\n', strings.shift());
|
||||||
assert.equal('foo bar hop\n', strings.shift());
|
assert.equal('foo bar hop\n', strings.shift());
|
||||||
assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
|
assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
|
||||||
|
assert.equal('Trace: This is a {"formatted":"trace"} 10 foo',
|
||||||
process.stderr.write('hello world');
|
strings.shift().split('\n').shift());
|
||||||
|
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
console.timeEnd('no such label');
|
console.timeEnd('no such label');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user