Continuing from a feature request I made for a way to output debug information going INTO a node

I've made a subflow that you can place inline with your flow that will just output the msg object or the msg.payload and can be enabled and disabled. But for the life of me, I can't get it to display its status. I've read the forum and searched and I can't see any real current documentation on node status.

This is what I've got so far. Have a look and somebody, please tell me what I'm missing. Specifically, I'm trying to show the status on the subflow node when it is in a regular flow. See the attached image. it should be showing a green ring or a dot underneath the node depending on whether the option to output the msg object or msg payload is selected in the env variables. Along with text to indicate what it's going to do. Intermittently, I have see the node display the word "off" where the status normally would appear with no ring or dot. But I have not used the word "off" in any of my attempts to display anything.

The debug functionality of the subflow works fine. It does output to the debug tab, the msg object or the msg.payload and can be enabled and disabled. That's all good.

Oh, and I'm using node-red version 0.20.7
and nodejs version v8.16.0

image

[
    {
        "id": "c2bcad1.0c3e4d",
        "type": "subflow",
        "name": "Inline Debug",
        "info": "This is a debug node that can be placed inline\nso you can see what's going into another node,\nor passing through a node",
        "category": "",
        "in": [
            {
                "x": 160,
                "y": 180,
                "wires": [
                    {
                        "id": "bd6896fe.f4e21"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 560,
                "y": 170,
                "wires": [
                    {
                        "id": "bd6896fe.f4e21",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "payloadOnly",
                "type": "bool",
                "value": "true"
            },
            {
                "name": "enabled",
                "type": "bool",
                "value": "true"
            }
        ],
        "icon": "node-red/debug.png",
        "status": {
            "x": 560,
            "y": 220,
            "wires": [
                {
                    "id": "bd6896fe.f4e21",
                    "port": 1
                }
            ]
        }
    },
    {
        "id": "bd6896fe.f4e21",
        "type": "function",
        "z": "c2bcad1.0c3e4d",
        "name": "debugOutputFunction",
        "func": "var x,y;\n\nx = env.get('enabled');\ny = env.get('payloadOnly');\n\n//payload only\nif (x===true & y===true){\nnode.warn(msg.payload);\nstatus = ({fill:\"green\",shape:\"dot\",text:\"output:msg.payload\"});\n}\n\n//output entire msg object\nif (x===true & y===false){\nnode.warn(msg);\nstatus = ({fill:\"green\",shape:\"ring\",text:\"output:msg object\"});\n}\n\nvar status;\n\nreturn [msg,status];",
        "outputs": 2,
        "noerr": 0,
        "x": 360,
        "y": 180,
        "wires": [
            [],
            []
        ]
    }
]
1 Like

At the end of your function you have

...
node.warn(msg);
status = ({fill:"green",shape:"ring",text:"output:msg object"});
}

var status;

return [msg,status];

thus you are re-initialising (wiping out) the current status...
You need

...
node.warn(msg);
status = ({fill:"green",shape:"ring",text:"output:msg object"});
}

return [msg,{payload:status}];

to ensure you return a payload on the second output (that then feeds your status output).

1 Like

Extraneous stuff excised.

That return was left over from all the fiddling I've been doing and was not the culprit.

The other part of your answer worked. the

return [msg,{payload:status}];

payload bit is what I was missing. dammit.

Thanks.

Next step is to attach an optional inject node to toggle the output on or off without having to redeploy.