From 980e281096dd01d3b8daef82838c88de86961de3 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 17 Nov 2014 21:45:41 -0800 Subject: [PATCH] #185 add some comments, const, Daniel to authors, and changelog --- AUTHORS | 1 + CHANGES.md | 8 +++++--- lib/bunyan.js | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5f75400..b09cb99 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,3 +16,4 @@ Ryan Graham (https://github.com/rmg) Alex Kocharin (https://github.com/rlidwka) Andrei Neculau (https://github.com/andreineculau) Mihai Tomescu (https://github.com/matomesc) +Daniel Juhl (https://github.com/danieljuhl) diff --git a/CHANGES.md b/CHANGES.md index fce34d5..cd3a4e7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,9 @@ Known issues: ## bunyan 1.2.3 (not yet released) -(nothing yet) +- [issue #184] Fix log rotation for rotation periods > ~25 days. Before this + change, a rotation period longer than this could hit [the maximum setTimeout + delay in node.js](https://github.com/joyent/node/issues/8656). By Daniel Juhl. ## bunyan 1.2.2 @@ -36,8 +38,8 @@ Known issues: problems from older versions: The build is not attempted on Linux and Windows. The build spew is *not* emitted by default (use `V=1 npm install` to see it); instead a - short warning is emitted if the build fails. - + short warning is emitted if the build fails. + Also, importantly, the new dtrace-provider fixes working with node v0.11/0.12. diff --git a/lib/bunyan.js b/lib/bunyan.js index 8461118..c7119d6 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -1083,8 +1083,11 @@ RotatingFileStream.prototype._setupNextRot = function () { var self = this; this.rotAt = this._nextRotTime(); var delay = this.rotAt - Date.now(); - if (delay > 2147483647) { - delay = 2147483647; + // Cap timeout to Node's max setTimeout, see + // . + var TIMEOUT_MAX = 2147483647; // 2^31-1 + if (delay > TIMEOUT_MAX) { + delay = TIMEOUT_MAX; } this.timeout = setTimeout( function () { self.rotate(); }, @@ -1179,6 +1182,8 @@ RotatingFileStream.prototype.rotate = function rotate() { var self = this; var _DEBUG = false; + // If rotation period is > ~25 days, we have to break into multiple + // setTimeout's. See . if (self.rotAt && self.rotAt > Date.now()) { return self._setupNextRot(); }