Skip to content

Commit

Permalink
Deprecate DEBUG_FD (#405)
Browse files Browse the repository at this point in the history
* remove DEBUG_FD from readme

* deprecate DEBUG_FD

* remove arrow function

ES6 habbits hit hard :D
  • Loading branch information
TooTallNate authored and thebigredgeek committed Dec 28, 2016
1 parent 9a18d66 commit 62df220
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

Expand All @@ -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


Expand Down Expand Up @@ -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_:

Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(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;
var stream = 1 === fd ? process.stdout :
2 === fd ? process.stderr :
Expand Down

3 comments on commit 62df220

@fengmk2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a broken change, should release on v3, not v2!

@thebigredgeek
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a deprecation warning

@fengmk2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this warning log will send to stderr and will break some start up checks.

Please sign in to comment.