3.0.1 • Published 9 years ago

debug-stream v3.0.1

Weekly downloads
4,318
License
MIT
Repository
github
Last release
9 years ago

debug-stream

Use the debug module on a stream

npm install debug-stream

Usage

var debugStream = require('debug-stream')('my-app')

process.stdin
  .pipe(debugStream())
  .resume() // just drain it

// or if you're already using debug

var debug = require('debug')('my-app')
var debugStream = require('debug-stream')(debug)

process.stdin
  .pipe(debugStream())
  .resume()

Running the above program with DEBUG=* will use the debug module on every buffer/object in the stream.

You can add an optional format string as well

var debugStream = require('debug-stream')('my-app')

process.stdin
  .pipe(debugStream('process.stdin: %s'))
  .resume() // just drain it

The debug stream behaives as pass through stream so can just insert it in any existing pipe chain

inputStream
  .pipe(debugStream())
  .pipe(outputStream)

Browser support

As with debug, this module also supports the browser environment through either browserify or webpack.

To enable the functionality, you need to run require('debug').enable('*') in your console. It will persist this setting in localStorage, until you run require('debug').disable().

License

MIT