1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Only add _alias/z to log messages if they are defined

This commit is contained in:
Nick O'Leary 2018-04-18 10:28:51 +01:00
parent eccd5e9801
commit 25345302e8
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 11 additions and 7 deletions

View File

@ -222,11 +222,15 @@ function log_helper(self, level, msg) {
var o = { var o = {
level: level, level: level,
id: self.id, id: self.id,
z: self.z,
type: self.type, type: self.type,
_alias: self._alias,
msg: msg msg: msg
}; };
if (self._alias) {
o._alias = self._alias;
}
if (self.z) {
o.z = self.z;
}
if (self.name) { if (self.name) {
o.name = self.name; o.name = self.name;
} }

View File

@ -398,7 +398,7 @@ describe('Node', function() {
}); });
n.log("a log message"); n.log("a log message");
should.deepEqual({level:Log.INFO, id:n.id, should.deepEqual({level:Log.INFO, id:n.id,
type:n.type, msg:"a log message",_alias:undefined, z:'789'}, loginfo); type:n.type, msg:"a log message",z:'789'}, loginfo);
Log.log.restore(); Log.log.restore();
done(); done();
}); });
@ -410,7 +410,7 @@ describe('Node', function() {
}); });
n.log("a log message"); n.log("a log message");
should.deepEqual({level:Log.INFO, id:n.id, name: "barney", should.deepEqual({level:Log.INFO, id:n.id, name: "barney",
type:n.type, msg:"a log message",_alias:undefined, z:'789'}, loginfo); type:n.type, msg:"a log message",z:'789'}, loginfo);
Log.log.restore(); Log.log.restore();
done(); done();
}); });
@ -425,7 +425,7 @@ describe('Node', function() {
}); });
n.warn("a warning"); n.warn("a warning");
should.deepEqual({level:Log.WARN, id:n.id, should.deepEqual({level:Log.WARN, id:n.id,
type:n.type, msg:"a warning",_alias:undefined, z:'789'}, loginfo); type:n.type, msg:"a warning",z:'789'}, loginfo);
Log.log.restore(); Log.log.restore();
done(); done();
}); });
@ -444,7 +444,7 @@ describe('Node', function() {
var message = {a:1}; var message = {a:1};
n.error(null,message); n.error(null,message);
should.deepEqual({level:Log.ERROR, id:n.id, type:n.type, msg:"",_alias:undefined, z:'789'}, loginfo); should.deepEqual({level:Log.ERROR, id:n.id, type:n.type, msg:"",z:'789'}, loginfo);
flows.handleError.called.should.be.true(); flows.handleError.called.should.be.true();
flows.handleError.args[0][0].should.eql(n); flows.handleError.args[0][0].should.eql(n);
@ -468,7 +468,7 @@ describe('Node', function() {
var message = {a:2}; var message = {a:2};
n.error("This is an error",message); n.error("This is an error",message);
should.deepEqual({level:Log.ERROR, id:n.id, type:n.type, msg:"This is an error",_alias:undefined, z:'789'}, loginfo); should.deepEqual({level:Log.ERROR, id:n.id, type:n.type, msg:"This is an error",z:'789'}, loginfo);
flows.handleError.called.should.be.true(); flows.handleError.called.should.be.true();
flows.handleError.args[0][0].should.eql(n); flows.handleError.args[0][0].should.eql(n);