From 491eea3b33cb52da73a78b4f65a58b4f778ee197 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sun, 30 Mar 2014 08:59:20 -0700 Subject: [PATCH] change from stderr to stdout --- Readme.md | 15 +++++++-------- lib/debug.js | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index 6bf0571..8981f8a 100644 --- a/Readme.md +++ b/Readme.md @@ -11,7 +11,7 @@ $ npm install debug ## Usage With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. - + Example _app.js_: ```js @@ -57,14 +57,13 @@ setInterval(function(){ ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: - _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_ - + When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: + ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) - + ## Conventions - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". + If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". ## Wildcards @@ -74,7 +73,7 @@ setInterval(function(){ ## Browser support - Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. + Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. ```js a = debug('worker:a'); @@ -89,7 +88,7 @@ setInterval(function(){ }, 1200); ``` -## License +## License (The MIT License) diff --git a/lib/debug.js b/lib/debug.js index dca4f34..e7422e6 100644 --- a/lib/debug.js +++ b/lib/debug.js @@ -39,7 +39,7 @@ var prevColor = 0; * Is stdout a TTY? Colored output is disabled when `true`. */ -var isatty = tty.isatty(2); +var isatty = tty.isatty(1); /** * Select a color. @@ -108,7 +108,7 @@ function debug(name) { + fmt + '\u001b[3' + c + 'm' + ' +' + humanize(ms) + '\u001b[0m'; - console.error.apply(this, arguments); + console.log.apply(this, arguments); } function plain(fmt) { @@ -116,7 +116,7 @@ function debug(name) { fmt = new Date().toUTCString() + ' ' + name + ' ' + fmt; - console.error.apply(this, arguments); + console.log.apply(this, arguments); } colored.enabled = plain.enabled = true;