add option alwaysIncludePattern to dateTime appender to always use the filename with the pattern included when logging
This commit is contained in:
@@ -13,7 +13,7 @@ if (process.env.NODE_DEBUG && /\blog4js\b/.test(process.env.NODE_DEBUG)) {
|
||||
debug = function() { };
|
||||
}
|
||||
|
||||
function DateRollingFileStream(filename, pattern, options, now) {
|
||||
function DateRollingFileStream(filename, pattern, alwaysIncludePattern, options, now) {
|
||||
debug("Now is " + now);
|
||||
if (pattern && typeof(pattern) === 'object') {
|
||||
now = options;
|
||||
@@ -23,6 +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 = alwaysIncludePattern;
|
||||
if (this.alwaysIncludePattern) {
|
||||
this.baseFilename = filename;
|
||||
filename = filename + this.lastTimeWeWroteSomething;
|
||||
}
|
||||
debug("this.now is " + this.now + ", now is " + now);
|
||||
|
||||
DateRollingFileStream.super_.call(this, filename, options);
|
||||
@@ -43,7 +49,7 @@ DateRollingFileStream.prototype.shouldRoll = function() {
|
||||
|
||||
DateRollingFileStream.prototype.roll = function(filename, callback) {
|
||||
var that = this,
|
||||
newFilename = filename + this.previousTime;
|
||||
newFilename = this.baseFilename + this.previousTime;
|
||||
|
||||
debug("Starting roll");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user