a stream that stamps incoming newlines with a message
A through stream that stamps all incoming lines of data with a message and emits it back out
npm install stamp-stream
Usage is simple
var stamp = require'stamp-stream';var stream = stamp'hello ';streampipeprocessstdout; // "hello world\n" is printedstreamwrite'wor';streamwrite'ld\n';
You can make dynamic stamps as well by passing in a function instead
var lines = 0;var stream = stampreturn lines+++' '; // prefix with line number;streampipeprocessstdout; // "0 first\n1 second\n2 third\n" is printedstreamwrite'first\n';streamwrite'seco'streamwrite'nd\nthird\n';
Stamp-Stream can be useful to stamp output from an application with timestamp or similar.
Assume we have a file called
var stamp = require'stamp-stream';processstdinpipestampreturn toGMTString+' ';pipeprocessstdout;processstdinresume;
If we now call
node my-app.js | node stream.js all log messages from
my-app.js would be prefixed by a timestamp.