Read the statement by Michael Teeuw here.
Printing to output Terminal
-
I’m currently trying to modify some modules and can’t figure out how to consistently output to the terminal for my own debugging process.
I use console.log(“xxxxx”) in a “node_helper.js” file and it seems to print just fine. But when I go to the actual “module.js” file, nothing i put in the console.log(“xxxx”) goes to the terminal. Help please!
-
It you call console.log() in the module.js, the output will go to your browsers web-console. Have in mind, that the module.js is executed by your browser (client-like) when you open magicmirror there while the node_helper.js is executed when you start the magicmirror-server (server-like) and runs all the time. So to bring the output of your module.js to your terminal, you would have to send this data with a socketNotification to your node_helper.js and print it there.
-
@LukeCodewalker Thanks for helping me understand that. After poking around a bit, I found this topic: https://forum.magicmirror.builders/topic/86/how-to-troubleshoot
Am I correct in understanding that if I call a “console.log()” in a module.js, I should be able to see the output in the pm2 logs? Because right now I am having trouble with that.
I have no problem running the mirror with pm2, and I can pull the logs no problem. But all the logs show are just the typical startup stuff. None of the random text outputs I have tried to put in with “console.log()” command. Please help!
Thanks!
-
@ZTA0796
I don’t know your testing setup, but you usually can open up your browser (on your computer, not the pi) go tohttp://YOUR-PI-IP:8080and then open up your broswer’s console. In chrome (using windows) you pressctrl+shift+i, if you’re using firefox it’sctrl+shift+k. That’s where all of yourconsole.logmessages (from the module.js) will appear. But @LukeCodewalker is correct, you won’t see node_helper.js messages there. You can view those from the consoletail -f .pm2/logs/mm-out-0.log&tail -f .pm2/logs/mm-error-0.log. That is, if you’re using the pm2 autostart from here. -
@mochman Now I get it! Thanks so much for laying out the basics for me! First time dealing in server/client stuff and I’m starting to make sense of it in my head.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login