* `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
This reverts commit 8dd8345d1498b8c6a3c6d7f7f4ebc600cfd2195b.
We shouldn't have changed the original behavior, which
too many people are relying on at this point.
It's also technically a breaking change, which we shouldn't
have landed on a minor/patch version change. So in the interest
of not breaking people's logs in production, reverting this.
We can discuss in a new issue if we want to restore this patch
for a `v3` release, but at the moment I'm personally leaningo
towards *no*, for historical reasons (i.e. this is reminding
me of Node.js trying to remove `sys` if anybody reading this
remembers those days).
See the discussion in #250 for more backlog.
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.
We modify the `namespaces` argument directly for some reason,
which ends up saving input that ends up being invalid RegExp code
upon the next `load()`+`enable()` call combo.
Avoid that completely by just saving the input directly first thing.
Fixes browsers since they actually use the "saved" value.
Mobile Safari has a dumb feature where it goes ahead and throws an exception when trying to access the localStorage in private mode.
Other people with the same issue:
http://meta.stackoverflow.com/questions/123116/safari-5-1-2-log-in-doesnt-work
Simply wrapping the local storage access in a try/catch should do the trick...