From 4927e54e28ac9fa69d0f53b5e318f2a5a259be40 Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Wed, 17 Jul 2024 21:54:54 -0500 Subject: [PATCH] update dependencies --- package-lock.json | 6 +++--- src/devices/DeviceBase.ts | 32 ++++++++++++++++++-------------- src/platform.ts | 24 ++++++++++++++---------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 33c6dc9..b1e3807 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5545,9 +5545,9 @@ } }, "node_modules/is-core-module": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", - "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/src/devices/DeviceBase.ts b/src/devices/DeviceBase.ts index 7031061..45dc82d 100644 --- a/src/devices/DeviceBase.ts +++ b/src/devices/DeviceBase.ts @@ -102,48 +102,48 @@ export abstract class DeviceBase { */ async infoLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - this.log.info(`${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + this.log.info(`${this.accessory.displayName}`, String(...log)); } } async successLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - this.log.success(`${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + this.log.success(`${this.accessory.displayName}`, String(...log)); } } async debugSuccessLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - if (this.deviceLogging?.includes('debug')) { - this.log.success(`[DEBUG] ${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + if (await this.loggingIsDebug()) { + this.log.success(`[DEBUG] ${this.accessory.displayName}`, String(...log)); } } } async warnLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - this.log.warn(`${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + this.log.warn(`${this.accessory.displayName}`, String(...log)); } } async debugWarnLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - if (this.deviceLogging?.includes('debug')) { - this.log.warn(`[DEBUG] ${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + if (await this.loggingIsDebug()) { + this.log.warn(`[DEBUG] ${this.accessory.displayName}`, String(...log)); } } } async errorLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - this.log.error(`${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + this.log.error(`${this.accessory.displayName}`, String(...log)); } } async debugErrorLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { - if (this.deviceLogging?.includes('debug')) { - this.log.error(`[DEBUG] ${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + if (await this.loggingIsDebug()) { + this.log.error(`[DEBUG] ${this.accessory.displayName}`, String(...log)); } } } @@ -151,14 +151,18 @@ export abstract class DeviceBase { async debugLog(...log: any[]): Promise { if (await this.enablingDeviceLogging()) { if (this.deviceLogging === 'debug') { - this.log.info(`[DEBUG] ${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); - } else { - this.log.debug(`${this.device.ipaddress}: ${this.accessory.displayName}`, String(...log)); + this.log.info(`[DEBUG] ${this.accessory.displayName}`, String(...log)); + } else if (this.deviceLogging === 'debugMode') { + this.log.debug(`${this.accessory.displayName}`, String(...log)); } } } + async loggingIsDebug(): Promise { + return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug'; + } + async enablingDeviceLogging(): Promise { - return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard'; + return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug' || this.deviceLogging === 'standard'; } } \ No newline at end of file diff --git a/src/platform.ts b/src/platform.ts index 8b91d02..3bf33b3 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -675,17 +675,17 @@ export class RainbirdPlatform implements DynamicPlatformPlugin { this.platformLogging = this.config.options?.logging ?? 'standard'; if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') { this.platformLogging = this.config.options.logging; - if (this.platformLogging?.includes('debug')) { + if (await this.loggingIsDebug()) { this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`); } } else if (this.debugMode) { this.platformLogging = 'debugMode'; - if (this.platformLogging?.includes('debug')) { + if (await this.loggingIsDebug()) { this.debugWarnLog(`Using ${this.platformLogging} Logging`); } } else { this.platformLogging = 'standard'; - if (this.platformLogging?.includes('debug')) { + if (await this.loggingIsDebug()) { this.debugWarnLog(`Using ${this.platformLogging} Logging`); } } @@ -723,7 +723,7 @@ export class RainbirdPlatform implements DynamicPlatformPlugin { async debugSuccessLog(...log: any[]): Promise { if (await this.enablingPlatformLogging()) { - if (this.platformLogging?.includes('debug')) { + if (await this.loggingIsDebug()) { this.log.success('[DEBUG]', String(...log)); } } @@ -737,7 +737,7 @@ export class RainbirdPlatform implements DynamicPlatformPlugin { async debugWarnLog(...log: any[]): Promise { if (await this.enablingPlatformLogging()) { - if (this.platformLogging?.includes('debug')) { + if (await this.loggingIsDebug()) { this.log.warn('[DEBUG]', String(...log)); } } @@ -751,7 +751,7 @@ export class RainbirdPlatform implements DynamicPlatformPlugin { async debugErrorLog(...log: any[]): Promise { if (await this.enablingPlatformLogging()) { - if (this.platformLogging?.includes('debug')) { + if (await this.loggingIsDebug()) { this.log.error('[DEBUG]', String(...log)); } } @@ -759,15 +759,19 @@ export class RainbirdPlatform implements DynamicPlatformPlugin { async debugLog(...log: any[]): Promise { if (await this.enablingPlatformLogging()) { - if (this.platformLogging === 'debugMode') { - this.log.debug(String(...log)); - } else if (this.platformLogging === 'debug') { + if (this.platformLogging === 'debug') { this.log.info('[DEBUG]', String(...log)); + } else if (this.platformLogging === 'debugMode') { + this.log.debug(String(...log)); } } } + async loggingIsDebug(): Promise { + return this.platformLogging === 'debugMode' || this.platformLogging === 'debug'; + } + async enablingPlatformLogging(): Promise { - return this.platformLogging?.includes('debug') || this.platformLogging === 'standard'; + return this.platformLogging === 'debugMode' || this.platformLogging === 'debug' || this.platformLogging === 'standard'; } }