From faf1fc3d86e3cdafa59d35c5ad541fd8eb0e9be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:00:55 +0100 Subject: [PATCH 1/2] Fix issue if this plugin is used outside of jeedom --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8ae0bb4..09913e4 100755 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ 'use strict'; let Access, Accessory, Service, Characteristic, AdaptiveLightingController, UUIDGen; +const fs = require('fs'); const inherits = require('util').inherits; const myLogger = require('./lib/myLogger').myLogger; const debug = {}; @@ -59,7 +60,11 @@ function JeedomPlatform(logger, config, api) { DEV_DEBUG = true; } this.debugLevel = config.debugLevel || debug.ERROR; - this.log = myLogger.createMyLogger(this.debugLevel,logger,api.user.storagePath()+'/../../../../log/'); + let logPath = api.user.storagePath()+'/../../../../log/' + if (!fs.existsSync(logPath)) { + logPath = '/tmp/' + } + this.log = myLogger.createMyLogger(this.debugLevel,logger,logPath); this.log('debugLevel:'+this.debugLevel); this.myPlugin = config.myPlugin; this.adaptiveEnabled = config.adaptiveEnabled; From e8e304f875caf8b9dcae22f3960dc835dd81e7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:16:21 +0100 Subject: [PATCH 2/2] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 09913e4..28d1f01 100755 --- a/index.js +++ b/index.js @@ -60,9 +60,9 @@ function JeedomPlatform(logger, config, api) { DEV_DEBUG = true; } this.debugLevel = config.debugLevel || debug.ERROR; - let logPath = api.user.storagePath()+'/../../../../log/' + let logPath = api.user.storagePath()+'/../../../../log/'; if (!fs.existsSync(logPath)) { - logPath = '/tmp/' + logPath = '/tmp/'; } this.log = myLogger.createMyLogger(this.debugLevel,logger,logPath); this.log('debugLevel:'+this.debugLevel);