-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
Description
Hi,
If I want to change out the adapter host or port for example, using setConfig(), it'll work unless I've logged at least one message. If I have sent a log message, then I have to null out the adapter property for setConfig() to work for the new adapterOptions.
I'm not sure if this wanted behaviour or if setConfig should be nulling the property when adapterOptions is updated. Would you say this is a bug or wanted behaviour?
Example below, just changing port number.
var log = require("gelf-pro");
log.setConfig({
adapterOptions: {
host: "GraylogServer.lan",
port: 10001,
family: 4,
timeout: 1000,
key: fs.readFileSync(`${root}/tls/cert.key`), // tcp-tls only
cert: fs.readFileSync(`${root}/tls/cert.pem`), // tcp-tls only
},
});
log.info(`Should error because wrong port`, {}, function (err, bytesSent) {
if (err) {
console.log(`Error in log:`, err);
}
});
setTimeout(function () {
log.setConfig({
adapterOptions: {
host: "GraylogServer.lan",
port: 10002,
family: 4,
timeout: 1000,
key: fs.readFileSync(`${root}/tls/cert.key`),
cert: fs.readFileSync(`${root}/tls/cert.pem`),
},
});
log.adapter = null; // Without this the below will error because it didn't get an updated adapter property, as it's created on first log message from the config provided by setConfig() above
log.info(`should use 10002 input on the graylog server not 10001`, {}, function (err, bytesSent) {
if (err) {
console.log(`Error in log:`, err);
}
});
}, 5000);Reactions are currently unavailable