mirror of
https://github.com/debug-js/debug.git
synced 2026-01-18 16:12:38 +00:00
change from stderr to stdout
This commit is contained in:
parent
db73b661fd
commit
491eea3b33
15
Readme.md
15
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(){
|
||||
|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user