I've read through the docs about logging here Logging : Node-RED where it mentions that there's several log levels. However... I haven't found how I can actually log to these different levels in a function node. What I have observed however is that
node.error() produces error
node.log() produces info
but where are the other log levels and how do I produce a log with that level?
console there's no filtering whatsoever, I guess this is what nodered uses under the hood?
Did it occur to you that if
console has those functions, maybe
node does as well?
If ever you want to discover what properties an object might have, this is good code to know:
msg.payload = Object.keys(node)
Add a debug node after that function node and you will see all of the properties.
That didn't occour to me at all
With that said though it would probably be a good idea to explicitly state this in the documentation.
Cause to me running
Object.keys(someObject) on every framework related object doesn't feel like a good developer experience. I'd be happy to make PR for it but I can't find a documentation repo.
I believe all of the relevant properties of the node object ARE documented. The
object.keys trick is just that, a quick and dirty trick do dump the structure of an object.
Actually, it is a pretty decent developer experience for something quick and dirty when you don't want to hunt through the documentation I certainly wouldn't expect anyone to have to do that regularly.
In this case, the logging functions follow a very standard naming convention anyway. And they are indeed documented.
I had a hard time finding that section when googling as I could only find the Logging : Node-RED page. Suggested a change in the docs so hopefully no one else does the same mistake.
[Docs] Add link to logging API in logging section by brolaugh · Pull Request #307 · node-red/node-red.github.io · GitHub
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.