MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Printing to output Terminal

    Scheduled Pinned Locked Moved Troubleshooting
    5 Posts 3 Posters 4.5k Views 3 Watching
    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 Offline
      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!

      LukeCodewalkerL mochmanM 2 Replies Last reply Reply Quote 0
      • LukeCodewalkerL Offline
        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 Offline
          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
          • mochmanM Offline
            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 Offline
              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

              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
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy