Read the statement by Michael Teeuw here.
Consolidate logging to browser console
-
I wanted to share a simple approach to unify logging across module components that I found incredibly useful during development. This will put all* logging in a browser console and remove the need to monitor pm2/pi console logs.
In your main module code (MMM-ABC.js), where you define your sockets simply add:
if (notification === 'HELPER_MESSAGE') { if (this.config.debug === 1) { Log.info(payload); } //Receive a message, log the payload to the browser console. }In your node_helper.js module, construct and send messages:
if (self.config.debug === 1) { apiMessage = moment().format('YYYY-MM-DD>>HH:mm:ss.SSSZZ') + ' [node_helper] << your log message content here >>'; self.sendSocketNotification('HELPER_MESSAGE', apiMessage); }Hope this helps on your development journey!
*any code errors / exceptions will still throw to the raspberry pi console / pm2
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