Minimal lightweight logging for Homey Apps
This module will be used in a Homey app to send logs to the TelemetryCollector App.
This module is implemented as a mixin pattern to simplify the use of the interface.
(For more information about mixins, see: > Useful Links > Mixins)
npm install homey-telemetrycollector-api
"permissions": ["homey:app:org.cflat-inc.telemetryCollector"]
require('homey-telemetrycollector-api').install;
this.logDebug('So easy it goes');
Error: error conditions
this.logError('logError-Message');
Warning: warning conditions
this.logWarning('logWarning-Message');
Notice: normal but significant condition
this.logNotice('logNotice-Message');
Informational: informational messages
this.logInfo('logInfo-Message');
Debug: debug-level messages
this.logDebug('logDebug-Message');
'use strict';
const Homey = require('homey');
// Install the TelemetryCollector Api
require('homey-telemetrycollector-api').install;
// Development
const inspector = require('node:inspector');
if (process.env.DEBUG === '1') {
try {
inspector.waitForDebugger();
} catch (err) {
inspector.open(9229, '0.0.0.0', true);
}
}
module.exports = class MyApp extends Homey.App {
async onInit() {
// ...
this.logInfo('App has been initialized');
}
};
Rename the methods, it's fast (global search & replace), the code is more readable and the method calls the console message at the end anyway.
- this.log() > (renameTo) > this.logInfo()
- this.error() > (renameTo) > this.logError()
- this.debug() > (renameTo) > this.logDebug()
Special thanks to all for the help in testing the new version.
Use at your own risk. I accept no responsibility for any damages caused by using this app.
© Chris Gross / cflat-inc.org, 2025