|
|
|
@ -23,10 +23,12 @@ function DateRollingFileStream(filename, pattern, options, now) {
|
|
|
|
|
this.pattern = pattern || '.yyyy-MM-dd';
|
|
|
|
|
this.now = now || Date.now;
|
|
|
|
|
this.lastTimeWeWroteSomething = format.asString(this.pattern, new Date(this.now()));
|
|
|
|
|
this.alwaysIncludePattern = false;
|
|
|
|
|
this.baseFilename = filename;
|
|
|
|
|
|
|
|
|
|
if (options) {
|
|
|
|
|
if (options.alwaysIncludePattern) {
|
|
|
|
|
this.alwaysIncludePattern = true;
|
|
|
|
|
filename = filename + this.lastTimeWeWroteSomething;
|
|
|
|
|
}
|
|
|
|
|
delete options.alwaysIncludePattern;
|
|
|
|
@ -75,8 +77,13 @@ DateRollingFileStream.prototype.roll = function(filename, callback) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renameTheCurrentFile(cb) {
|
|
|
|
|
debug("Renaming the " + filename + " -> " + newFilename);
|
|
|
|
|
fs.rename(filename, newFilename, cb);
|
|
|
|
|
if (this.alwaysIncludePattern) {
|
|
|
|
|
// no-op
|
|
|
|
|
cb();
|
|
|
|
|
} else {
|
|
|
|
|
debug("Renaming the " + filename + " -> " + newFilename);
|
|
|
|
|
fs.rename(filename, newFilename, cb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|