@zwave-js/winston-daily-rotate-file
Version:
A transport for winston which logs to a rotating file each day.
39 lines (28 loc) • 854 B
JavaScript
;
var Stream = require('stream');
var util = require('util');
module.exports = WritableStream;
util.inherits(WritableStream, Stream.Writable);
function WritableStream(options) {
Stream.Writable.call(this, options);
}
WritableStream.prototype.write = function () {
var ret = Stream.Writable.prototype.write.apply(this, arguments);
if (!ret) {
this.emit('drain');
}
return ret;
};
WritableStream.prototype._write = function (chunk, encoding, callback) {
this.write(chunk, encoding, callback);
};
WritableStream.prototype.toString = function () {
return this.toBuffer().toString();
};
WritableStream.prototype.toBuffer = function () {
var buffers = [];
this._writableState.getBuffer().forEach(function (data) {
buffers.push(data.chunk);
});
return Buffer.concat(buffers);
};