Fixes for version v0.10 streams, breaks log4js for older versions of node
This commit is contained in:
@@ -4,9 +4,9 @@ var BaseRollingFileStream = require('./BaseRollingFileStream'),
|
||||
fs = require('fs'),
|
||||
async = require('async');
|
||||
|
||||
function debug(message) {
|
||||
function debug() {
|
||||
// util.debug(message);
|
||||
// console.log(message);
|
||||
// console.log.apply(console, arguments);
|
||||
}
|
||||
|
||||
module.exports = RollingFileStream;
|
||||
@@ -28,6 +28,7 @@ function RollingFileStream (filename, size, backups, options) {
|
||||
util.inherits(RollingFileStream, BaseRollingFileStream);
|
||||
|
||||
RollingFileStream.prototype.shouldRoll = function() {
|
||||
debug("should roll with current size %d, and max size %d", this.currentSize, this.size);
|
||||
return this.currentSize >= this.size;
|
||||
};
|
||||
|
||||
@@ -81,30 +82,11 @@ RollingFileStream.prototype.roll = function(filename, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function openANewFile(cb) {
|
||||
debug("Opening a new file");
|
||||
fs.open(
|
||||
filename,
|
||||
that.options.flags,
|
||||
that.options.mode,
|
||||
function (err, fd) {
|
||||
debug("opened new file");
|
||||
var oldLogFileFD = that.fd;
|
||||
that.fd = fd;
|
||||
that.writable = true;
|
||||
fs.close(oldLogFileFD, cb);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
debug("Starting roll");
|
||||
debug("Queueing up data until we've finished rolling");
|
||||
debug("Flushing underlying stream");
|
||||
this.flush();
|
||||
|
||||
async.series([
|
||||
renameTheFiles,
|
||||
openANewFile
|
||||
], callback);
|
||||
debug("Rolling, rolling, rolling");
|
||||
async.series([
|
||||
this.closeTheStream.bind(this),
|
||||
renameTheFiles,
|
||||
this.openTheStream.bind(this)
|
||||
], callback);
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user