From f1472a95e95099d72bcbe0edfd2745d26a0a1304 Mon Sep 17 00:00:00 2001 From: Christian Weimann Date: Sun, 7 Jan 2024 11:07:20 +0100 Subject: [PATCH] Improve logging --- utils/timer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/utils/timer.js b/utils/timer.js index bc1ee92..1701863 100644 --- a/utils/timer.js +++ b/utils/timer.js @@ -1,31 +1,31 @@ -console.loggerName = 'js.timer'; -console.log('Load timer module'); +const log = Java.type('org.slf4j.LoggerFactory').getLogger('js.utils.timer'); +log.info('Load utils.timer'); class Timer { #timers = new Object(); constructor() { - console.log('Initialization of timer helper class'); + log.info('Initialization of timer helper class'); } create(identifier, timeout, func) { - console.debug(`Create timer with identifier ${identifier}`); + log.debug(`Create timer with identifier ${identifier}`); this.#timers[identifier] = actions.ScriptExecution.createTimer(identifier, timeout, func); } cancel(identifier) { // Return if no timer with the respactive identifier is available if (!this.#timers.hasOwnProperty(identifier)) { - console.debug(`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.debug(`Timer with identifier ${identifier} not running. Cancel anyway`); + log.debug(`Timer with identifier ${identifier} not running. Cancel anyway`); } else { - console.debug(`Cancel timer with identifier ${identifier}`); + log.debug(`Cancel timer with identifier ${identifier}`); } // Cancel timer @@ -43,7 +43,7 @@ class Timer { // Return if no timers available if (timers.length == 0) { - console.debug('No timers available to cancel'); + log.debug('No timers available to cancel'); return false; }