diff --git a/README.md b/README.md index 1f3b08e1..9157bfc4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # debug -[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) +[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) @@ -149,6 +149,7 @@ change the behavior of the debug logging: | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | +| `DEBUG_HIDE_TTY_DATE` | Hide date from debug output on TTY. | __Note:__ The environment variables beginning with `DEBUG_` end up being @@ -269,7 +270,7 @@ enabled or disabled. - TJ Holowaychuk - Nathan Rajlich - Andrew Rhyne - + ## Backers Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)] diff --git a/src/node.js b/src/node.js index b85ec7e3..fc725ce2 100644 --- a/src/node.js +++ b/src/node.js @@ -23,7 +23,7 @@ exports.useColors = useColors; * Colors. */ -exports.colors = [ 6, 2, 3, 4, 5, 1 ]; +exports.colors = [6, 2, 3, 4, 5, 1]; try { var supportsColor = require('supports-color'); @@ -80,7 +80,7 @@ function useColors() { * Map %o to `util.inspect()`, all on a single line. */ -exports.formatters.o = function(v) { +exports.formatters.o = function (v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts) .replace(/\s*\n\s*/g, ' '); @@ -90,7 +90,7 @@ exports.formatters.o = function(v) { * Map %o to `util.inspect()`, allowing multiple lines if needed. */ -exports.formatters.O = function(v) { +exports.formatters.O = function (v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts); }; @@ -113,8 +113,15 @@ function formatArgs(args) { args[0] = prefix + args[0].split('\n').join('\n' + prefix); args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); } else { - args[0] = new Date().toISOString() - + ' ' + name + ' ' + args[0]; + args[0] = getDate() + name + ' ' + args[0]; + } +} + +function getDate() { + if ('hideTtyDate' in exports.inspectOpts && exports.inspectOpts.hideTtyDate) { + return ''; + } else { + return new Date().toISOString() + ' '; } } @@ -161,7 +168,7 @@ function load() { * differently for a particular `debug` instance. */ -function init (debug) { +function init(debug) { debug.inspectOpts = {}; var keys = Object.keys(exports.inspectOpts);