MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Printing to output Terminal

    Troubleshooting
    3
    5
    3336
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      ZTA0796 last edited by

      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!

      LukeCodewalker mochman 2 Replies Last reply Reply Quote 0
      • LukeCodewalker
        LukeCodewalker Module Developer @ZTA0796 last edited by

        @ZTA0796

        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.

        Z 1 Reply Last reply Reply Quote 0
        • Z
          ZTA0796 @LukeCodewalker last edited by

          @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!

          1 Reply Last reply Reply Quote 0
          • mochman
            mochman Module Developer @ZTA0796 last edited by

            @ZTA0796
            I don’t know your testing setup, but you usually can open up your browser (on your computer, not the pi) go to http://YOUR-PI-IP:8080 and then open up your broswer’s console. In chrome (using windows) you press ctrl+shift+i, if you’re using firefox it’s ctrl+shift+k. That’s where all of your console.log messages (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 console tail -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.

            Z 1 Reply Last reply Reply Quote 0
            • Z
              ZTA0796 @mochman last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy