diff --git a/utils/TimerMgr.js b/utils/TimerMgr.js index e8b9a4e..19ffd10 100644 --- a/utils/TimerMgr.js +++ b/utils/TimerMgr.js @@ -1,32 +1,31 @@ // Logging -console.loggerName = "org.openhab.js.utils.TimerMgr"; -console.log("Loading utils.TimerMgr"); +const log = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.js.utils.TimerMgr'); class TimerMgr { #timers = new Object(); constructor() { - console.info('Initialization of TimerMgr helper class'); + log.info('Initialization of TimerMgr helper class'); } create(id, timeout, func) { - console.log("Create timer with id " + id); + log.debug("Create timer with id " + id); this.#timers[id] = actions.ScriptExecution.createTimer(id, timeout, func); } cancel(identifier) { // Return if no timer with the respactive identifier is available if (!this.#timers.hasOwnProperty(identifier)) { - console.log(`No timer with identifier ${identifier} available to cancel`); + log.debug(`No timer with identifier ${identifier} available to cancel`); return false; } // Check if timer is active if (!this.#timers[identifier].isActive()) { - console.log(`Timer with identifier ${identifier} not running. Cancel anyway`); + log.debug(`Timer with identifier ${identifier} not running. Cancel anyway`); } else { - console.log(`Cancel timer with identifier ${identifier}`); + log.debug(`Cancel timer with identifier ${identifier}`); } // Cancel timer @@ -48,7 +47,7 @@ class TimerMgr { // Return if no timers available if (timers.length == 0) { - console.log('No timers available to cancel'); + log.debug('No timers available to cancel'); return false; }