28 Commits

Author SHA1 Message Date
Andrew E. Rhyne
a31178c8d8 hotfix for babel-core 2016-12-20 21:31:53 -08:00
Yami
f42b962792 refactor: Moved source files to /src. Moved test files to client and server side tests. Added karma for front-end testing. 2016-12-16 15:19:40 +00:00
Nathan Rajlich
e58d54b46f Node: configurable util.inspect() options (#327)
* `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
2016-12-12 15:13:35 -08:00
Nathan Rajlich
00f3046c30 Node: %O (big O) pretty-prints the object (#322)
* %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
2016-12-12 11:13:19 -08:00
Nathan Rajlich
475e7b31f3 some random optimizations
Hopefully…
2016-11-07 10:46:22 -08:00
Andrew E. Rhyne
820f351906 Merge pull request #215 from gorangajic/add-ms-as-last-param
move ms to the last place
2016-10-27 17:43:53 -07:00
Goran Gajic
dafc16e7b3 move ms to the last place 2016-10-27 13:44:53 +02:00
Thomas Parisot
7748e508f1 Add %O formatter to reflect Chrome's console.log capability
refs #278
2016-05-10 20:55:19 +01:00
Dario Marcelino
92eaeede1a Issue #182: replace high intensity foreground color for bold 2015-03-02 13:03:33 +00:00
Nathan Rajlich
e4d021a223 node: implement DEBUG_FD env variable support
Closes #146.
2014-10-15 14:19:59 -07:00
Stephen Mathieson
345996b982 node.js: Use stderr rather than stdout for logging
Closes #120
2014-08-05 13:49:16 -04:00
Nathan Rajlich
68e8139416 Merge pull request #108 from timoxley/console_error
Make console.x configurable.
2014-06-07 23:53:05 -07:00
Tim Oxley
dd32a4c902 Make console logging function configurable.
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.
2014-06-07 23:34:39 -07:00
Nathan Rajlich
83f38e56ac node: fix %o colors on old node <= 0.8.x 2014-06-07 23:15:10 -07:00
David M. Lee
3aa365ae93 Don't set DEBUG if namespaces is undefined.
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.
2014-06-06 15:01:50 -05:00
Nathan Rajlich
9fdd3313be node: type comment typo 2014-06-05 00:35:26 -07:00
Nathan Rajlich
872115d10a make ms diff be global, not be scope
Closes #88.
Closes #90.
2014-06-02 11:36:49 -07:00
Nathan Rajlich
48114629b4 node: fix typo and optimize useColors() logic 2014-06-01 14:21:26 -07:00
Nathan Rajlich
e0b6b07cb6 node: make DEBUG_COLORS able to disable coloring
Fixes #59.
2014-06-01 11:09:55 -07:00
Nathan Rajlich
e502a7df95 *: export the colors array
DRYs up some of the logic in the process,
since the "core" color handling code gets
moved to `debug.js`

Closes #20.
2014-06-01 10:32:30 -07:00
Nathan Rajlich
9e4e0fff23 node: reset terminal color for the debug content
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.
2014-05-31 19:21:53 -07:00
Nathan Rajlich
32b0bf41eb browser, node: rename c to color
More clear for the user to override it this way.
See: #95
2014-05-31 19:18:41 -07:00
Nathan Rajlich
b38496e03b node: map "%o" to util.inspect() 2014-05-31 14:24:59 -07:00
Nathan Rajlich
007123fa11 node: fix colors in strict mode
Before the `fmt` variable was not being updated.

Closes #70.
2014-05-31 12:22:05 -07:00
Nathan Rajlich
f3eb1a5396 node: don't default save() to an empty string 2014-05-30 22:13:46 -07:00
Nathan Rajlich
fbbf2ca884 node: , -> . 2014-05-30 00:18:17 -07:00
Nathan Rajlich
0c6d452292 node: apply log to console
Not necessary, just seems more "proper"
2014-05-30 00:15:29 -07:00
Nathan Rajlich
2cffe24185 rewrite: abstract common logic for Node & browsers 2014-05-30 00:10:10 -07:00