diff --git a/oe-logger/oe-logger.html b/oe-logger/oe-logger.html index acae4c4..29e9678 100644 --- a/oe-logger/oe-logger.html +++ b/oe-logger/oe-logger.html @@ -9,18 +9,15 @@ color : '#87a980', defaults : { flowName : { - value : "" - }, - message : { - value : "" + value : "node-red-flow" }, levelOfLog : { - value : "" + value : "info" }, complete: {value:"false", required:true} }, inputs : 1, - outputs : 1, + outputs : 0, icon : "oeCloudLogo.svg", label : function() { return this.name || "oe-logger"; @@ -59,10 +56,6 @@ -
- - -
@@ -76,7 +69,7 @@
- +
@@ -85,10 +78,7 @@ \ No newline at end of file +

Message - property of msg to logged (default: msg.payload).

+ diff --git a/oe-logger/oe-logger.js b/oe-logger/oe-logger.js index a76518d..5cfe8ee 100644 --- a/oe-logger/oe-logger.js +++ b/oe-logger/oe-logger.js @@ -13,16 +13,13 @@ module.exports = function(RED) { this.context = node.callContext.ctx; this.flowName = config.flowName; if (this.flowName === '') { - this.flowName = 'default-flow'; + this.flowName = 'node-red-flow'; } this.levelOfLog = config.levelOfLog; if (this.levelOfLog === '') { this.levelOfLog = 'info'; } - this.message = {}; - if (config.message !== '') { - this.message.message = config.message; - } + this.message; this.log = oeLogger(this.flowName); this.complete = (config.complete||"payload").toString(); if (this.complete === "false") { @@ -30,7 +27,7 @@ module.exports = function(RED) { } node.on('input', function(msg) { if (this.complete === "true") { - this.message.msg = msg; + this.message = msg; } if (this.complete !== "true") { var property = "payload"; @@ -43,16 +40,19 @@ module.exports = function(RED) { output = undefined; } } - this.message[property] = output; + this.message = output; } if (msg && msg.ctx && msg.ctx.options) { context = msg.ctx.options; } else if (msg && msg.callContext) { context = msg.callContext; } - this.log[this.levelOfLog](context, JSON.stringify(this.message)); - node.send(msg); + if (typeof this.message === 'object') { + this.log[this.levelOfLog](context, JSON.stringify(this.message)); + } else { + this.log[this.levelOfLog](context, this.message); + } }); } RED.nodes.registerType("oe-logger", OeLoggerNode); -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 9f57475..70df8a7 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "destroy-data": "destroy-data/destroy-data.js", "find-data": "find-data/find-data.js", "decision-table": "rule-engine-decision-table/decision-table.js", - "oe-logger":"oe-logger/oe-logger.js" + "oe-logger": "oe-logger/oe-logger.js" } }, "author": "Sachin Mane",