Continuing the discussion from Survey: logging to debug sidebar:
As a (half-beginner) I've started to enhance a node, to make it work with multiple I2C buses.
I'm writing my progress down to show how difficult is it for us, Newbies to get along with version 1.2.6
(Don't get me wrong, I love NR from the first screenshot I've seen it! Just some user-help improvements would boost a lot on nice experience, spare time and learning would be easier about it.)
1. Examples from github
- Found code here,
- copied into a Function,
- spent a half hour to find out how fix the "required" error,
- than came the big surprice:
NOTHING. No error, no warning, no info, no output on the sidebar.
2. global.log(), global.info(),
After wathing 30+ YT videos and reading 1000 pages of documentation over the last 2 month my head is filled totally up to the top. Still, I remembered something like:
- There was something about a
.warn('...')
function. - code-extension does not work, so typing "global." shows no list of choices
- RED.warn() did not work either
- Somehow I remembered it should be used capitalized: ... so tried also ...WARN() variations.
- ... and many more trials.
3. No info/help on main page
Looking at : logging... (Which is totally deepwater for a beginners anyway.)
or at error handling ...
or even at cookbook error handling
not a single hint is there.
One single line would have had helped a lot!
You can use
node.debug('a='+a)
in a script inside a Function Node for sidebar-debugging.
See more here (link) ...
... At least the first link logging... helped me to my next discovery:
4. Finding the console
- So here I am, spent 1.5 hours to find out:
$ node-red-log
must be running from a console to view the log !!!- It hides usually behind the browers, so not too much help exept if you have a 2th monitor attached.
- IMHO there should be an alias too:
$ node-red-console
to keep naming consecvence.
So basically it wasn't me, not doing the job right, but the output went to a wrong place.
One solution could be to place a button on the Debug Tab with a counter to show "there is more behind". Something like this:
5. Forum search failures
https://discourse.nodered.org/search?q=debug%20function
My first search ended up at this comment.
- Great! Finally I know the KEYWORD IS:
node.XYZ()
- (Still no auto-code-extension does, so typing "node." shows no list of choices. )
- So let's try:
node.info('Show Me!');
(Why I've tried "info()", and not "error()" or "warn()" ?
Because: I'd like to use warn() for problems. Not for simple infos.)
The Result:
NOTHING. NADA. Emptyness...
... many many other searches, no simple solution.
That's how I've discovered the prev. topic.
My oppinion:
- there should be MORE ways to do that, not just one. It's better to have 20 alias function for a thing as important than this than one hidden only.
6. SideBar help (Bug?)
Finally I remembered, each node has a built-in help.
And YESSSS, Function has one too, with valuable information:
... So let's try it out:
node.log("My Logggg");
Aaaaaaand Result iiiiiiis:
A big piece of nothing. As usual.
That was the point I gave up and started this topic.
[{"id":"f3b2c9de.38ea7","type":"group","z":"34aad6f7.b85c6a","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["c7bd2502.8cab","fbdac8f7.f88548"],"x":74,"y":639,"w":372,"h":82},{"id":"c7bd2502.8cab","type":"inject","z":"34aad6f7.b85c6a","g":"f3b2c9de.38ea7","name":"Test Log","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":180,"y":680,"wires":[["fbdac8f7.f88548"]]},{"id":"fbdac8f7.f88548","type":"function","z":"34aad6f7.b85c6a","g":"f3b2c9de.38ea7","name":"test debug","func":"\n console.log('anything happening?');\n\nnode.log(\"My Logggg message\"); \n\n//node.warn('nodeW');\n//node.info('nodeI');\n//node.debug('nodeD');\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":680,"wires":[[]]}]