From f5a76d9073bbbd77fa83eb1c86058935b6385d16 Mon Sep 17 00:00:00 2001 From: Xiaolu Liu Date: Thu, 24 Apr 2014 00:07:11 +0900 Subject: [PATCH] file won't get rolled if the process restarted daily --- lib/streams/DateRollingFileStream.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/streams/DateRollingFileStream.js b/lib/streams/DateRollingFileStream.js index 9da029a..0ac3ec5 100644 --- a/lib/streams/DateRollingFileStream.js +++ b/lib/streams/DateRollingFileStream.js @@ -17,7 +17,14 @@ 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())); + + if (fs.existsSync(filename)) { + var stat = fs.statSync(filename); + this.lastTimeWeWroteSomething = format.asString(this.pattern, stat.mtime); + } else { + this.lastTimeWeWroteSomething = format.asString(this.pattern, new Date(this.now())); + } + this.baseFilename = filename; this.alwaysIncludePattern = false;