From 0ed9f6cc4f7deede85013bd77784b6b3e5ab71c3 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 28 Feb 2015 13:45:23 +0200 Subject: [PATCH] Adding an Object node to the sandbox of a function node Permit the user of the sandbox to log using the Function Node. Test provided and working. Fix Display warning message in the debug log Before they were displayed as error instead of warning --- nodes/core/core/58-debug.html | 10 +++- nodes/core/core/80-function.html | 7 +++ nodes/core/core/80-function.js | 12 ++++ test/nodes/core/core/80-function_spec.js | 70 +++++++++++++++++++++++- 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/nodes/core/core/58-debug.html b/nodes/core/core/58-debug.html index 093bf1f76..5349ce82d 100644 --- a/nodes/core/core/58-debug.html +++ b/nodes/core/core/58-debug.html @@ -196,8 +196,14 @@ ''; // NOTE: relying on function error to have a "type" that all other msgs don't if (o.hasOwnProperty("type") && (o.type === "function")) { - msg.className = 'debug-message debug-message-level-20'; - msg.innerHTML += '[function] : (error)'; + var errorLvlType = 'error'; + var errorLvl = 20; + if (o.hasOwnProperty("level") && o.level === 30) { + errorLvl = 30; + errorLvlType = 'warn' + } + msg.className = 'debug-message debug-message-level-' + errorLvl; + msg.innerHTML += '[function] : (' + errorLvlType + ')'; } else { msg.innerHTML += ''+(o.topic?topic+' : ':'')+ (o.property?'[msg.'+property+']':'[msg]')+" : "+typ+''; diff --git a/nodes/core/core/80-function.html b/nodes/core/core/80-function.html index cef0809d8..f581574ac 100644 --- a/nodes/core/core/80-function.html +++ b/nodes/core/core/80-function.html @@ -39,6 +39,13 @@

The message is passed in as a JavaScript object called msg.

By convention it will have a msg.payload property containing the body of the message.

+

If your node need to log anything use the node object: +

+

The function should return the messages it wants to pass on to the next nodes in the flow. It can return: