mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
added some logging info
parent
4df7805220
commit
1cf5c027bf
@ -30,6 +30,33 @@ cd ~/MagicMirror/
|
|||||||
npm run config:check
|
npm run config:check
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Logging Errors and info to "console"
|
||||||
|
|
||||||
|
It's not clear to first time users what is the "console" or where it is. The reason is that it depends on what is producing the log call, where it is produced and how.
|
||||||
|
|
||||||
|
To keep things as brief as possible, to debug using the JS `console.log()` calls, there are various variations available. In the MM core there are some logging wrappers that can be used in your core *MMM-something.js* code. These are:
|
||||||
|
|
||||||
|
```js
|
||||||
|
Log.info('error'); # To log to stderr
|
||||||
|
Log.log('log'); # To log to stdout
|
||||||
|
Log.error('info'); # To log to stdout
|
||||||
|
```
|
||||||
|
|
||||||
|
However, from within your *node_helper.js*, if you have one, these are not available (AFAIK), so there you have to use the standard JS loggers. There are quite a [few variations](https://console.spec.whatwg.org/#namespacedef-console) of those, with various success rates, depending on where you want the message to appear.
|
||||||
|
|
||||||
|
* Do you want your log message to go to the Browser (DevTools) log?
|
||||||
|
* Do you want your log message to go to the MagicMirror debug log?
|
||||||
|
Such as in: `~/.pm2/logs/mm-out.log` () or `~/.pm2/logs/mm-out.log` (), when running MM using *pm2*.
|
||||||
|
* Do you want the logs to show up when running in: *npm start dev*?
|
||||||
|
|
||||||
|
The one logger that always seem to do the trick is:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.error(any... data)
|
||||||
|
console.dir(any item, optional object? options)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
There are probably many other and better ways to check and debug. So please add and edit this page or file an issue with info for improving debugging.
|
There are probably many other and better ways to check and debug. So please add and edit this page or file an issue with info for improving debugging.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user