Skip to content

Commit

Permalink
Updated stdout/stderr example
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarcelino committed Mar 13, 2015
1 parent 9e61ecb commit e48f365
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,26 @@ setInterval(function(){

You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally:

Example _stderr.js_:
Example _stdout.js_:

```js
var debug = require('../');
var log = debug('app:log');
var debug = require('debug');
var error = debug('app:error');

// by default console.log is used
log('goes to stdout!');
// by default stderr is used
error('goes to stderr!');

var error = debug('app:error');
// set this namespace to log via console.error
error.log = console.error.bind(console); // don't forget to bind to console!
error('goes to stderr');
log('still goes to stdout!');
var log = debug('app:log');
// set this namespace to log via console.log
log.log = console.log.bind(console); // don't forget to bind to console!
log('goes to stdout');
error('still goes to stderr!');

// set all output to go via console.warn
// set all output to go via console.info
// overrides all per-namespace log settings
debug.log = console.warn.bind(console);
log('now goes to stderr via console.warn');
error('still goes to stderr, but via console.warn now');
debug.log = console.info.bind(console);
error('now goes to stdout via console.info');
log('still goes to stdout, but via console.info now');
```

## Authors
Expand Down

0 comments on commit e48f365

Please sign in to comment.