Skip to content

Commit

Permalink
Merge pull request #186 from dmarcelino/181-stderr_stdout
Browse files Browse the repository at this point in the history
181 stderr vs stdout
  • Loading branch information
TooTallNate committed Mar 13, 2015
2 parents 105497d + e48f365 commit 5b613b3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 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
17 changes: 0 additions & 17 deletions example/stderr.js

This file was deleted.

17 changes: 17 additions & 0 deletions example/stdout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var debug = require('../');
var error = debug('app:error');

// by default stderr is used
error('goes to stderr!');

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.info
// overrides all per-namespace log settings
debug.log = console.info.bind(console);
error('now goes to stdout via console.info');
log('still goes to stdout, but via console.info now');

0 comments on commit 5b613b3

Please sign in to comment.