Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Expose debug.colored and debug.colors #20

Closed
wants to merge 1 commit into from

4 participants

@langpavel

Not ideal, but someone can found this usefull.

Feel free to keep this open for discussion.

See also #17 - A way to force colored output, this patch NOT solving this via ENV variable.

@contra

+1 to this - I need to emit logs over the network so I wrapped debug in another function that does both but lost the pretty colors :(

@atrefz

+1

@TooTallNate TooTallNate closed this pull request from a commit
@TooTallNate TooTallNate *: export the `colors` array
DRYs up some of the logic in the process,
since the "core" color handling code gets
moved to `debug.js`

Closes #20.
e502a7d
@TooTallNate
Owner

Fixed in e502a7d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 6, 2012
  1. @langpavel
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/debug.js
View
10 lib/debug.js
@@ -33,7 +33,7 @@ var names = []
* Colors.
*/
-var colors = [6, 2, 3, 4, 5, 1];
+debug.colors = [2, 3, 4, 5, 1, 6];
/**
* Previous debug() call.
@@ -51,7 +51,7 @@ var prevColor = 0;
* Is stdout a TTY? Colored output is disabled when `true`.
*/
-var isatty = tty.isatty(2);
+debug.colored = tty.isatty(2);
/**
* Select a color.
@@ -61,7 +61,7 @@ var isatty = tty.isatty(2);
*/
function color() {
- return colors[prevColor++ % colors.length];
+ return debug.colors[prevColor++ % debug.colors.length];
}
/**
@@ -114,7 +114,7 @@ function debug(name) {
prev[name] = curr;
fmt = ' \033[9' + c + 'm' + name + ' '
- + '\033[3' + c + 'm\033[90m'
+ + '\033[3' + c + 'm' + '\033[0m' //+ '\033[90m'
+ fmt + '\033[3' + c + 'm'
+ ' +' + humanize(ms) + '\033[0m';
@@ -129,7 +129,7 @@ function debug(name) {
colored.enabled = plain.enabled = true;
- return isatty
+ return debug.colored
? colored
: plain;
}
Something went wrong with that request. Please try again.