Hi,
one of the long-standing quirks of the Function node is that the only way to get a message to appear in the Debug sidebar is to use node.warn
or node.error
.
The problem with this approach is it puts what should be debugging comments into the log at warn/error levels. That is not a good thing for systems that monitor warn/error levels and automatically raise alerts when they happen.
The question is: how can we improve this? It isn't a hard problem to solve, but there are a few different ways it could be solved. So I'm interested in the community's feedback on the possible options.
There are three proposals:
-
Use
console.log
to write to the Debug sidebar. JavaScript developers will be familiar withconsole.log
and they can already use it today to write to the log output of Node-RED directly. However - that is also why it isn't an ideal choice - it already writes to the stdout of Node-RED outside of the log handling which isn't ideal. -
Use
node.debug
- we already support the other log levels from within the Function node - but they only appear in the log output if you have the log level set appropriately. The proposal here is to treatnode.debug
as a special case and have that appear in the Debug sidebar regardless of the underlying log level. -
Introduce a new command,
debug()
, explicitly for the purpose of writing to the Debug sidebar. This would not appear in the log output.
There is a separate idea of adding the ability to control what log levels the Debug sidebar displays, but that is part of a wider review of how you can filter and select what the Debug sidebar shows. The purpose of this post is the very specific question of how to log to Debug from the Function node.
What do you think? Pick an option and vote. If you think there's another option I've missed, please add a comment.
console.log()
node.debug()
debug()
- something else - please comment
0 voters