winston-daily-rotate-file
Advanced tools
Comparing version 1.1.3 to 1.1.4
15
index.js
@@ -72,3 +72,3 @@ 'use strict'; | ||
this.timestamp = options.timestamp ? options.timestamp : true; | ||
this.datePattern = options.datePattern ? options.datePattern : 'yyyy-MM-dd'; | ||
this.datePattern = options.datePattern ? options.datePattern : '.yyyy-MM-dd'; | ||
this.depth = options.depth || null; | ||
@@ -602,13 +602,14 @@ this.eol = options.eol || os.EOL; | ||
DailyRotateFile.prototype._getFilename = function () { | ||
if (this.datePattern.substring(0, 1) === '.') { | ||
this.datePattern = this.datePattern.substring(1); | ||
} | ||
var formattedDate = this.getFormattedDate(); | ||
if (this.prepend) { | ||
return [formattedDate, this._basename].join('.'); | ||
if (this.datePattern === '.yyyy-MM-dd') { | ||
this.datePattern = 'yyyy-MM-dd.'; | ||
formattedDate = this.getFormattedDate(); | ||
} | ||
return formattedDate + this._basename; | ||
} | ||
return [this._basename, formattedDate].join('.'); | ||
return this._basename + formattedDate; | ||
}; | ||
@@ -615,0 +616,0 @@ |
{ | ||
"name": "winston-daily-rotate-file", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "A transport for winston which logs to a rotating file each day.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -64,2 +64,12 @@ /* eslint-disable max-nested-callbacks,no-unused-expressions */ | ||
it('should not add leading dot if one is not provided with datePattern', function () { | ||
var now = moment().format('YYYY-MM-DD'); | ||
var transport = new DailyRotateFile({ | ||
filename: path.join(fixturesDir, 'log'), | ||
datePattern: '-yyyy-MM-dd.log' | ||
}); | ||
expect(transport._getFilename()).to.equal('log-' + now + '.log'); | ||
}); | ||
it('should remove leading dot if one is provided with datePattern when prepend option is true', function () { | ||
@@ -66,0 +76,0 @@ var now = moment().format('YYYY-MM-DD'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28218
736