app.js
/**
   * onInit is called when the app is initialized.
   */
onInit is called when the app is initialized.
onInit is called when the app is initialized .
async onInit() {
    this.log('MyApp has been initialized');
    this.homey.settings.set('logger', JSON.stringify({ logs: [] }));
    const saveLog = (type, message) => {
      const s = this.homey.settings.get('logger');
      const log = s ? JSON.parse(s) : {logs: []};
      log.logs.push({time: new Date().toLocaleString(), message, type});
      this.homey.settings.set('logger', JSON.stringify(log));
    };
    this.logger = {
      debug: (message) => {
        console.debug(message);
      },
      log: (message) => {
        console.log(message);
      },
      warn: (message) => {
        console.warn(message);
      },
      info: (message) => {
        console.info(message);
      },
      error: (message) => {
        console.error(message);
        saveLog('error', message);
      }
    };
  }
async onInit ( ) { this . log ( 'MyApp has been initialized' ) ; this . homey . settings . set ( 'logger' , JSON . stringify ( { logs : [ ] } ) ) ; const saveLog = ( type , message ) => { const s = this . homey . settings . get ( 'logger' ) ; const log = s ? JSON . parse ( s ) : { logs : [ ] } ; log . logs . push ( { time : new Date ( ) . toLocaleString ( ) , message , type } ) ; this . homey . settings . set ( 'logger' , JSON . stringify ( log ) ) ; } ; this . logger = { debug : ( message ) => { console . debug ( message ) ; } , log : ( message ) => { console . log ( message ) ; } , warn : ( message ) => { console . warn ( message ) ; } , info : ( message ) => { console . info ( message ) ; } , error : ( message ) => { console . error ( message ) ; saveLog ( 'error' , message ) ; } } ; }
onInit is called when the app is initialized.
onInit is called when the app is initialized .
// saveLog('debug', message); // saveLog('log', message); // saveLog('warn', message); // saveLog('info', message);