• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Debugging

Scheduled Pinned Locked Moved Development
22 Posts 7 Posters 17.6k Views 6 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.
  • K Offline
    KirAsh4 Moderator
    last edited by Jun 22, 2016, 5:01 AM

    Nothing would appear in the terminal, it’s not the STDOUT facility that you’re using. The console.log() facility logs to the browser’s console log. With most browsers, you access this by pressing F12. This is what my desktop looks like when I’m coding. Note that this is a Windows machine with dual monitors. On the left monitor is my code editor, split into two panels so I can look at multiple files at the same time. The files are being opened directly from the MagicMirror folder on the Raspberry Pi. On the right is a Chrome browser open with the Raspberry Pi’s IP address. That loads up the mirror display. And by hitting F12, I get the console panel that you see open, and at the bottom you can see the debugging messages that I put in the code to track. I can write/change code in the editor, hit Save, then hit Refresh in Chrome and get instant feedback. All of that is completely independent of what’s actually being displayed on the Raspberri Pi’s monitor.

    The panel also allows me to see the actual HTML being returned (by selecting Elements at the top.) So any code that I write, I can verify the HTML bit, and I can follow along with any errors or other messages that I put in the code. When the mirror code fails for some reason, I can look in the console and try to figure out where the error lies.

    0_1466571359041_mirrorcoding.png

    A Life? Cool! Where can I download one of those from?

    1 Reply Last reply Reply Quote 0
    • E Offline
      Eunanibus Module Developer
      last edited by Jun 22, 2016, 10:37 PM

      Your last post helped immensely! Thank you!

      1 Reply Last reply Reply Quote 0
      • E Offline
        Eunanibus Module Developer
        last edited by Jun 23, 2016, 11:05 PM

        Sorry to keep on this. Is there a particular way I’m able to look at a particular object’s available functions in console (if there is a way, I can’t see it and google is turning up zilch)

        1 Reply Last reply Reply Quote 0
        • K Offline
          KirAsh4 Moderator
          last edited by Jun 23, 2016, 11:40 PM

          I suspect the answer is: go read the source code … but, what are you trying to do?

          A Life? Cool! Where can I download one of those from?

          1 Reply Last reply Reply Quote 0
          • E Offline
            Eunanibus Module Developer
            last edited by Jun 23, 2016, 11:41 PM

            It’s my source code :laughing: - My object should have an available function to me, but it’s coming up function not found. I’m gonna keep digging! New module is on its way.

            1 Reply Last reply Reply Quote 0
            • K Offline
              KirAsh4 Moderator
              last edited by Jun 23, 2016, 11:42 PM

              Theeeeen you’re not defining it as a function … ?

              A Life? Cool! Where can I download one of those from?

              1 Reply Last reply Reply Quote 0
              • A Offline
                alexyak
                last edited by Jul 25, 2016, 3:03 PM

                You don’t have to run the the code in the electron every time. I would just run “node index” from the /serveronly folder and start the chrome with dev tools on my dev box. Also as dev tool Visual Studio Code is a very good one and runs on Windows, Linux and OS X. You could configure it to debug the node.js as well as the chrome client (via a plugin) locally or even have a remote debugging session.

                1 Reply Last reply Reply Quote 0
                • B Offline
                  bobbob601
                  last edited by bobbob601 Sep 11, 2016, 6:45 PM Sep 11, 2016, 4:21 PM

                  Hi,

                  I’m trying to dev a module too and I’m trying to debug too. Sadly I get a white screen, like when the config file is incorrect. I’m pretty sure the config file is OK, because the only thing I add is

                  {
                  		        module: 'MMM-Ratp',
                  		        position: 'top_right'
                      		},
                  

                  Where MMM-Ratp is the name of my module.

                  I tried to use the console (I’m using firefox) and it works fine when MM is running, but when I get a white screen under Epifany webbrowser (default one), under Firefox, I get “Unable to connect” like if the web server was not running so I don’t have any log and I don’t know whether it is a code error in my plugin, or something more stupid like denied access to one specific file or anything else I forgot like registering the module

                  I then did a test with a Helloword plugin, it works fine. Then I copy the HW code to my plugin.js, just renaming the file and then it’s not working. I thought that the issue would be an access denied but doing ls -al (I’m noob with linux), the chmod seem to be the same for both plugin (read access)

                  Any idea where to start digging ? thx

                  [edit] I’m moving forward. it was because as soon as placed in the module folder, the node_helper seems to be parsed and executed and I had some modules required which were not installed. Now, the module is loaded but not working. I continue digging :)

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    BenRoe Module Developer
                    last edited by Sep 18, 2016, 2:36 PM

                    I could not use Log.log('foobar'); in the node_helper.js and if i use console.log('foobar'); the log is shown in the CLI. Is there a solution to show it in the Browser Console?

                    S 1 Reply Last reply Sep 18, 2016, 2:39 PM Reply Quote 0
                    • S Offline
                      strawberry 3.141 Project Sponsor Module Developer @BenRoe
                      last edited by Sep 18, 2016, 2:39 PM

                      @BenRoe quote from the readme The Magic Mirror contains a convenience wrapper for logging. Currently, this logger is a simple proxy to the original console.log methods. But it might get additional features in the future. The Loggers is currently only available in the core module file (not in the node_helper). so everything you have experinced is as it should be

                      instead of logging in the node_helper directly you could send the string, objects, etc. to your module and use the logger there to view it in the browsers console

                      Please create a github issue if you need help, so I can keep track

                      S 1 Reply Last reply Apr 26, 2018, 8:43 AM Reply Quote 2
                      • 1
                      • 2
                      • 3
                      • 2 / 3
                      • 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