From cab0af1ee978b59ac5c7dccf293fa75d95840a1e Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 27 Dec 2016 15:40:01 -0800 Subject: [PATCH 1/3] remove DEBUG_FD from readme --- README.md | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ff244814..2c57ddfa 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,6 @@ Then, run the program to be debugged as usual. |-----------|-------------------------------------------------| | `DEBUG` | Enables/disabled specific debugging namespaces. | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | -| `DEBUG_FD`| File descriptor to output debug logs to. Defaults to stderr. | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | @@ -110,8 +109,6 @@ Then, run the program to be debugged as usual. [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) for the complete list. - __Note:__ Certain IDEs (such as WebStorm) don't support colors on stderr. In these cases you must set `DEBUG_COLORS` to `1` and additionally change `DEBUG_FD` to `1`. - ## Formatters @@ -181,13 +178,10 @@ setInterval(function(){ ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) -## Output streams - -### stderr vs stdout - By default `debug` will log to stderr, however this can be changed by setting the environment variable `DEBUG_FD` to `1` for stdout and `2` for stderr (the default value). +## Output streams -You can also set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: + By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method: Example _stdout.js_: @@ -211,15 +205,6 @@ error('now goes to stdout via console.info'); log('still goes to stdout, but via console.info now'); ``` -### Save debug output to a file - -You can save all debug statements to a file by piping them. - -Example: - -```bash -$ DEBUG_FD=3 node your-app.js 3> whatever.log -``` ## Authors From 06f7337d58f8dbccb20c0c73948bd241ef021aba Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 27 Dec 2016 16:02:22 -0800 Subject: [PATCH 2/3] deprecate DEBUG_FD --- src/node.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/node.js b/src/node.js index 15bf55af..9b65cddc 100644 --- a/src/node.js +++ b/src/node.js @@ -58,6 +58,10 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { * $ DEBUG_FD=3 node script.js 3>debug.log */ +if ('DEBUG_FD' in process.env) { + util.deprecate(() => {}, '`DEBUG_FD` is deprecated. Override `debug.log` if you want to use a different log function (https://git.io/vMUyr)')() +} + var fd = parseInt(process.env.DEBUG_FD, 10) || 2; var stream = 1 === fd ? process.stdout : 2 === fd ? process.stderr : From 6992189126146c409c69c79e4e96089baa7238d7 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 27 Dec 2016 16:05:29 -0800 Subject: [PATCH 3/3] remove arrow function ES6 habbits hit hard :D --- src/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 9b65cddc..ea6a8967 100644 --- a/src/node.js +++ b/src/node.js @@ -59,7 +59,7 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { */ if ('DEBUG_FD' in process.env) { - util.deprecate(() => {}, '`DEBUG_FD` is deprecated. Override `debug.log` if you want to use a different log function (https://git.io/vMUyr)')() + util.deprecate(function(){}, '`DEBUG_FD` is deprecated. Override `debug.log` if you want to use a different log function (https://git.io/vMUyr)')() } var fd = parseInt(process.env.DEBUG_FD, 10) || 2;