Skip to content

Commit

Permalink
minor fixes for logger node
Browse files Browse the repository at this point in the history
  • Loading branch information
raghav135 committed Aug 13, 2017
1 parent 32781c7 commit 9dbcf9a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
24 changes: 7 additions & 17 deletions oe-logger/oe-logger.html
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -59,10 +56,6 @@
<label for="node-input-flowName"><i class="icon-tag"></i> Flow Name</label>
<input type="text" id="node-input-flowName" placeholder="Flow Name">
</div>
<div class="form-row">
<label for="node-input-message"><i class="icon-tag"></i> Message</label>
<input type="text" id="node-input-message" placeholder="Message">
</div>
<div class="form-row">
<label for="node-input-levelOfLog"><i class="icon-tag"></i> Level</label>
<!--<input type="select" id="node-input-levelOfLog">-->
Expand All @@ -76,7 +69,7 @@
</select>
</div>
<div class="form-row">
<label for="node-input-typed-complete"><i class="fa fa-list"></i> <span data-i18n="debug.output"></span></label>
<label for="node-input-typed-complete"><i class="fa fa-list"></i> Message</label>
<input id="node-input-typed-complete" type="text" style="width: 70%">
<input id="node-input-complete" type="hidden">
</div>
Expand All @@ -85,10 +78,7 @@
<script type="text/x-red" data-help-name="oe-logger">
<p>Node that logs a message using oe-logger.</p>
<p><b>Properties:</b></p>
<p><i>Flow Name</i> - the name of the logger, typically the name of the flow (default: 'default-flow').</p>
<p><i>Message</i> - the message to be logged (default: empty).</p>
<p><i>Flow Name</i> - the name of the logger, typically the name of the flow (default: 'node-red-flow').</p>
<p><i>Level</i> - the level of log (default: 'Info').</p>
<p><i>Add to log</i> - property of <i>msg</i> to be added to log (default: msg.payload).</p>
<p><b>Output:</b></p>
<p>At the end of the logging operation, the node invokes <i>node.send(msg)</i> to send msg to the next node.</p>
</script>
<p><i>Message</i> - property of <i>msg</i> to logged (default: msg.payload).</p>
</script>
20 changes: 10 additions & 10 deletions oe-logger/oe-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,21 @@ 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") {
this.complete = "payload";
}
node.on('input', function(msg) {
if (this.complete === "true") {
this.message.msg = msg;
this.message = msg;
}
if (this.complete !== "true") {
var property = "payload";
Expand All @@ -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);
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9dbcf9a

Please sign in to comment.