bunyan-rotating-file-stream
bunyan-rotating-file-stream copied to clipboard
Rotate existing not rotating at correct interval
When a file is less than 24 hours old (daily), initialPeriodCheck fails to trigger new file creation. Next Rotation time checks 24 hours since birthtime instead of at midnight of the day after birthtime, causing no new file to be created at startup.
Relevant code:
// initialperiodtrigger.js
function checkIfRotationNeeded(birthtime, now) {
var nextRot = birthtime;
var lastRot = birthtime;
while (nextRot < now) {
lastRot = nextRot;
nextRot = nextRotTime(lastRot, periodScope, periodNum);
}
return { needsRotation: lastRot != birthtime, rotateTo: lastRot };
}
// nextrotationtime.js
case 'd':
if (rotAt) {
newRotAt = rotAt + periodNum * 24 * 60 * 60 * 1000;
} else {
// First time: start of tomorrow (i.e. at the coming midnight) UTC.
newRotAt = Date.UTC(d.getUTCFullYear(), d.getUTCMonth(),
d.getUTCDate() + 1);
}
break;
e.g. if file is created at 11:30am Mar 28, rotAt is passed in as 11:30am Mar 28, and newRotAt returns 11:30am Mar 29, so if the time is after Midnight on Mar 29, but before 11:30am, no new file is created.
From looking at the code it looks like this issue will be with hourly and weekly as well.
Facing the same issue for ms as well... do we have any update on this?