diff --git a/doc/api/console.markdown b/doc/api/console.markdown index 6e2de6071e64a2..a8fc78b8d03c41 100644 --- a/doc/api/console.markdown +++ b/doc/api/console.markdown @@ -48,6 +48,10 @@ is used on each argument. See [util.format()][] for more information. Same as `console.log`. +### console.debug(object [,object, ...]) + +Same as `console.log`. + ### console.error([data][, ...]) Same as `console.log` but prints to stderr. @@ -56,6 +60,10 @@ Same as `console.log` but prints to stderr. Same as `console.error`. +### console.exception(object [, object, ...]) + +Same as `console.error`. + ### console.dir(obj[, options]) Uses `util.inspect` on `obj` and prints resulting string to stdout. This function diff --git a/lib/console.js b/lib/console.js index d2b4f3fc5b59be..9c401e3838d50e 100644 --- a/lib/console.js +++ b/lib/console.js @@ -40,6 +40,9 @@ Console.prototype.log = function() { Console.prototype.info = Console.prototype.log; +Console.prototype.debug = Console.prototype.log; + + Console.prototype.warn = function() { this._stderr.write(util.format.apply(this, arguments) + '\n'); }; @@ -48,6 +51,9 @@ Console.prototype.warn = function() { Console.prototype.error = Console.prototype.warn; +Console.prototype.exception = Console.prototype.warn; + + Console.prototype.dir = function(object, options) { this._stdout.write(util.inspect(object, util._extend({ customInspect: false diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index a80c6e57e4b151..c760958fd0d26a 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -36,10 +36,19 @@ assert(!called); c.log('test'); assert(called); +assert.equal(Console.prototype.log, Console.prototype.debug); +assert.equal(c.log('test'), c.debug('test')); + called = false; c.error('test'); assert(called); +assert.equal(Console.prototype.error, Console.prototype.warn); +assert.equal(c.error('test'), c.warn('test')); + +assert.equal(Console.prototype.exception, Console.prototype.warn); +assert.equal(c.exception('test'), c.warn('test')); + out.write = function(d) { assert.equal('{ foo: 1 }\n', d); called = true;