<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Consolidate logging to browser console]]></title><description><![CDATA[<p dir="auto">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.</p>
<p dir="auto">In your main module code (MMM-ABC.js), where you define your sockets simply add:</p>
<pre><code>if (notification === 'HELPER_MESSAGE') {
     if (this.config.debug === 1) { Log.info(payload); }
//Receive a message, log the payload to the browser console. 
}

</code></pre>
<p dir="auto">In your node_helper.js module, construct and send messages:</p>
<pre><code>if (self.config.debug === 1) {
         apiMessage = moment().format('YYYY-MM-DD&gt;&gt;HH:mm:ss.SSSZZ') + ' [node_helper] &lt;&lt; your log message content here &gt;&gt;';
         self.sendSocketNotification('HELPER_MESSAGE', apiMessage);
}
</code></pre>
<p dir="auto">Hope this helps on your development journey!</p>
<p dir="auto">*any code errors / exceptions will still throw to the raspberry pi console / pm2</p>
]]></description><link>https://forum.magicmirror.builders/topic/7039/consolidate-logging-to-browser-console</link><generator>RSS for Node</generator><lastBuildDate>Thu, 21 May 2026 05:06:15 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/7039.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Apr 2018 11:54:53 GMT</pubDate><ttl>60</ttl></channel></rss>