Function node's OnStart - no logging possible?

Hy all,

I am relatively new to NodeRED and tinker around with function nodes.

As I wasn't to sure about the flow context concept, I tried to add debug lines into my node's OnStartup, but they nowhere appeared in the debug window.

Although I use the selected node context, debug messages from the same nodes OnMessage tab appear as expected in the debug window.

Am I missing something, or is debugging in the OnStartup really not possible?

Thanks

Welcome to the forum @NodeWrangler

What sort of debug lines? If you mean you used console.log() then possibly they do not appear in the debug pane because they are run before node-red is fully started so the output gets lost. If you look in the node-red log you should see them.

Thanks for chiming in.

I ment node.log() statements. But it makes sense, they might not show up as NR is no started fully yet, when they are started.

If you use console.log() and look in the log as I suggested and it should be ok. I don't know what node.log() will do in this situation.

node.log does not write to the debug sidebar at any time. It only writes to the console log.

You can use node.warn to write to the debug sidebar at any time.

There have been discussions in the past on giving the Function node a better logging API for the debug sidebar (rather than having to log everything as a warning). But not come to any final conclusion or contribution to make it so.

1 Like

Is there a design discussion somewhere that people could contribute to?

I think this was the last discussion on it đź“‹ Survey: logging to debug sidebar

1 Like

Thanks for clarifying this issue.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.