winston-daily-rotate-file
Advanced tools
Comparing version 2.0.0-rc.1 to 2.0.0-rc.2
@@ -11,2 +11,3 @@ 'use strict'; | ||
var compat = require('winston-compat'); | ||
var PassThrough = require('stream').PassThrough; | ||
var Transport = semver.major(winston.version) === 2 ? compat.Transport : require('winston-transport'); | ||
@@ -30,6 +31,3 @@ | ||
var DailyRotateFile = function (options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
options = options || {}; | ||
Transport.call(this, options); | ||
@@ -62,3 +60,4 @@ | ||
throwIf('stream', 'filename', 'maxsize'); | ||
this.logStream = options.stream; | ||
this.logStream = new PassThrough(); | ||
this.logStream.pipe(options.stream); | ||
} else { | ||
@@ -118,4 +117,6 @@ this.filename = options.filename ? path.basename(options.filename) : 'winston.log'; | ||
var noop = function () {}; | ||
if (semver.major(winston.version) === 2) { | ||
DailyRotateFile.prototype.log = function (level, msg, meta, callback) { | ||
callback = callback || noop; | ||
var options = Object.assign({}, this.options, { | ||
@@ -127,3 +128,5 @@ level: level, | ||
this._internalLog(options, callback); | ||
var output = compat.log(options) + options.eol; | ||
this.logStream.write(output); | ||
callback(null, true); | ||
}; | ||
@@ -133,16 +136,11 @@ } else { | ||
DailyRotateFile.prototype.log = function (info, callback) { | ||
var options = Object.assign({}, this.options, info); | ||
this._internalLog(options, callback); | ||
var MESSAGE = Symbol.for('message'); | ||
callback = callback || noop; | ||
this.logStream.write(info[MESSAGE] + this.options.eol); | ||
this.emit('logged', info); | ||
callback(null, true); | ||
}; | ||
} | ||
DailyRotateFile.prototype._internalLog = function (options, callback) { | ||
var opts = Object.assign({}, this.options, options); | ||
var output = compat.log(opts) + this.options.eol; | ||
this.logStream.write(output); | ||
if (callback) { | ||
callback(null, true); | ||
} | ||
}; | ||
DailyRotateFile.prototype.close = function () { | ||
@@ -149,0 +147,0 @@ if (this.logStream) { |
{ | ||
"name": "winston-daily-rotate-file", | ||
"version": "2.0.0-rc.1", | ||
"version": "2.0.0-rc.2", | ||
"description": "A transport for winston which logs to a rotating file each day.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,6 +19,16 @@ /* eslint-disable max-nested-callbacks,no-unused-expressions,handle-callback-err */ | ||
} else { | ||
transport.log({ | ||
var logger = winston.createLogger({ | ||
transports: [transport] | ||
}); | ||
transport.on('logged', function () { | ||
if (cb) { | ||
cb(null, true); | ||
} | ||
}); | ||
logger.info({ | ||
level: level, | ||
message: message | ||
}, cb); | ||
}); | ||
} | ||
@@ -25,0 +35,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
23068
11
468