Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide tty date #486

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions 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)

<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down
19 changes: 13 additions & 6 deletions src/node.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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, ' ');
Expand All @@ -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);
};
Expand All @@ -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() + ' ';
}
}

Expand Down Expand Up @@ -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);
Expand Down