winston-syslog
Advanced tools
Comparing version 2.1.0 to 2.2.0
# CHANGELOG | ||
## v2.2.0 / 2019-08-14 | ||
- #[82], (@AlexMost) allow use of a customer producer | ||
- #[109], (@gdvyas) Prevent error before connection is established | ||
- #[114], (@vrza) Support 'udp' as an alias of 'udp4' | ||
## v2.1.0 / 2019-02-17 | ||
@@ -4,0 +10,0 @@ |
@@ -27,2 +27,3 @@ /* | ||
warning: 3, | ||
warn: 3, | ||
error: 4, | ||
@@ -72,6 +73,7 @@ crit: 5, | ||
this.socket = null; | ||
this.producer = new glossy.Produce({ | ||
type: this.type, | ||
appName: this.appName, | ||
pid: this.pid, | ||
var Producer = options.customProducer || glossy.Produce; | ||
this.producer = new Producer({ | ||
type: this.type, | ||
appName: this.appName, | ||
pid: this.pid, | ||
facility: this.facility | ||
@@ -120,10 +122,11 @@ }); | ||
log(info, callback) { | ||
if (!~levels.indexOf(info[LEVEL])) { | ||
let level = info[LEVEL]; | ||
if (!~levels.indexOf(level)) { | ||
return callback(new Error('Cannot log unknown syslog level: ' + info[LEVEL])); | ||
} | ||
level = level === "warn" ? "warning" : level; | ||
const output = info[MESSAGE]; | ||
const syslogMsg = this.producer.produce({ | ||
severity: info[LEVEL], | ||
severity: level, | ||
host: this.localhost, | ||
@@ -144,3 +147,3 @@ date: new Date(), | ||
return callback(err); | ||
return callback(); | ||
} | ||
@@ -209,3 +212,3 @@ | ||
if (this.socket) { | ||
this.socket.close(); | ||
this.socket.destroy(); | ||
} | ||
@@ -229,3 +232,4 @@ | ||
// UDP protocol | ||
this.socket = new dgram.Socket(this.protocol); | ||
const proto = this.protocol === 'udp' ? 'udp4' : this.protocol; | ||
this.socket = new dgram.Socket(proto); | ||
} | ||
@@ -232,0 +236,0 @@ |
{ | ||
"name": "winston-syslog", | ||
"description": "A syslog transport for winston", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"author": "Charlie Robbins <charlie.robbins@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -65,2 +65,5 @@ # winston-syslog | ||
By default, syslog messages are produced by [glossy][3], but you can override that behavior by providing a | ||
custom **Producer** instance via the **customProducer** setting. | ||
## Log Levels | ||
@@ -67,0 +70,0 @@ Because syslog only allows a subset of the levels available in [winston][0], levels that do not match will be ignored. Therefore, in order to use `winston-syslog` effectively, you should indicate to [winston][0] that you want to use the syslog levels: |
@@ -122,2 +122,43 @@ 'use strict'; | ||
} | ||
}).addBatch({ | ||
'opening fake syslog server': { | ||
topic: function () { | ||
var self = this; | ||
server = dgram.createSocket('udp4'); | ||
server.on('listening', function () { | ||
self.callback(); | ||
}); | ||
server.bind(PORT); | ||
}, | ||
'Custom producer': { | ||
topic: function () { | ||
var self = this; | ||
server.once('message', function (msg) { | ||
self.callback(undefined, msg.toString()); | ||
}); | ||
function CustomProducer() {} | ||
CustomProducer.prototype.produce = function (opts) { | ||
return 'test ' + opts.message; | ||
}; | ||
transport = new winston.transports.Syslog({ | ||
port: PORT, | ||
customProducer: CustomProducer | ||
}); | ||
transport.log('debug', 'ping', null, function (err) { | ||
assert.ifError(err); | ||
}); | ||
}, | ||
'should apply custom syslog format': function (msg) { | ||
assert.equal(msg, 'test debug: ping'); | ||
transport.close(); | ||
} | ||
}, | ||
teardown: function () { | ||
server.close(); | ||
} | ||
} | ||
}).export(module); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
29196
709
139
3