* `formatArgs()` gets passed the args Array directly
Rather than working on `arguments`. The Node.js version
was for some reason turning the arguments into an Array
again so it was happening twice! This should make things
faster overall.
* whitespace
* rename `Readme.md` to `README.md`
* refactor the `debug()` constructor a bit
Now, debug instances are hot-enabelable. That is, you can
toggle the `debug.enabled` boolean on instances to enable
or disable an instance. There is still no global version of
this functionality.
Now all instances get a `useColors` and `colors` property,
even disabled ones, in case they get enabled later on. Boot-up
time impact should be negligible.
* node: allow configurable `util.inspect()` options
Via env variables by default. So to get more object depth,
you pass the `DEBUG_DEPTH=10` env var.
For the `showHidden` option, you set `DEBUG_SHOW_HIDDEN=on`.
See the Node.js docs for the complete list of `util.inspect()` options:
https://nodejs.org/api/util.html#util_util_inspect_object_options
* README: document inspect env variables
* %O (big O) pretty-prints the object
For example:
```js
var debug = require('./')('foo')
var o = {
foo: 'bar',
b: new Buffer(10),
c: Math.PI
}
debug('%O', o)
```
Previously:
```
foo { foo: 'bar', b: <Buffer 01 00 00 00 01 00 00 00 c0 82>, c: 3.141592653589793 } +0ms
```
Now:
```
foo { foo: 'bar',
foo b: <Buffer 01 00 00 00 01 00 00 00 c0 82>,
foo c: 3.141592653589793 } +0ms
```
This is a breaking change for anybody relying on the old `%O` behavior.
Though I don't think `%O` was working previously because the formatters
regexp wasn't checking for uppercase formatters (now fixed in this patch).
* use %O by default if no formatting string is given
* Readme: add Formatters section
Fixes#302.
* Readme: finish custom formatters example
Split log() into 2 methods: formatArgs() and log(), allowing log to be
overridden on a per-namespace or global level. Global log settings trump
per-namespace settings.
On Node.js, if you set a process.env field to either null or undefined,
it gets cast to string 'null' or 'undefined'.
For debug, this means that if you don't have DEBUG set, it will get set
to the string 'undefined'. There are other modules (like
node-rest-client) which use the DEBUG environment variable that will
start spewing debug output when you don't want it to.
This is a controversial change as well, but it seems to be
wanted by the community, and usability is more important to me
than looks, so why not…
Closes#47.
Closes#52.
Closes#87.