diff --git a/Module-Debugging.md b/Module-Debugging.md index e8a706f..aaa1cad 100644 --- a/Module-Debugging.md +++ b/Module-Debugging.md @@ -70,6 +70,8 @@ Log.log('log'); # To log to stdout Log.error('error'); # To log to stderr ``` +By default, these log entries will go to the "browser" web console which can be accessed from the DevTools. To start MagicMirror with DevTools open, run `npm start dev` from the MagicMirror folder. If you wish to send these browser logs to the normal console (or PM2 Log Files), add `export ELECTRON_ENABLE_LOGGING=true` to the top of `~/MagicMirror/run-start.sh` and restart. + ##### Logging From *node-helper.js* These are not available (AFAIK) if you are using a *node_helper.js*, so you'll have to use the standard JS loggers there. As mentioned, there are quite a [few variations](https://console.spec.whatwg.org/#namespacedef-console) of these (and they result in varying success rates) depending on where you want the message to appear. @@ -85,6 +87,8 @@ console.error(any... data) console.dir(any item, optional object? options) ``` +You may also want to take a look at the [MMM-Logging](https://github.com/shbatm/MMM-Logging) 3rd-party module, which will add timestamps and additional formatting to your `console.error()`, or `console.log()` calls. + #### Reviewing logs written to disk #### Check your PM2 logs with `pm2 logs mm` or check the log files in their locations: - `/home/pi/.pm2/pm2.log`