-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
29 lines (22 loc) · 790 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var ChunkyStream = require('chunky-stream');
var StdoutStream = require('./lib/stdout-stream');
var ThrottleStream = require('./lib/throttle-stream');
var CloudWatchStream = require('./lib/cloudwatch-stream');
module.exports = function (options, errorHandler) {
options = options || {};
options.ignoreEmpty = true;
var log = new CloudWatchStream(options);
var chunk = new ChunkyStream(options);
var throttle = new ThrottleStream();
var stdout = new StdoutStream(options);
chunk.use(require('./lib/max-length'));
chunk.use(require('./lib/max-size'));
if (typeof errorHandler === 'function') {
log.on('error', errorHandler);
}
log.on('flushed', function () {
stdout.emit('flushed')
});
stdout.pipe(chunk).pipe(throttle).pipe(log);
return stdout;
};