From de82bb041ceb4ce8f18cd0944e271072d37156eb Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Thu, 15 Apr 2021 16:43:09 -0400 Subject: [PATCH] Expose log level as a configuration option for zwave_js (#1950) --- zwave_js/DOCS.md | 14 ++++++++++++++ zwave_js/config.json | 4 +++- zwave_js/rootfs/etc/cont-init.d/config.sh | 10 +++++++++- zwave_js/rootfs/usr/share/tempio/zwave_config.conf | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/zwave_js/DOCS.md b/zwave_js/DOCS.md index 5ed9099..4f9a474 100644 --- a/zwave_js/DOCS.md +++ b/zwave_js/DOCS.md @@ -83,6 +83,20 @@ don't have a backup of this key, you won't be able to reconnect to any securely included devices. This may mean you have to do a factory reset on those devices and your controller, before rebuilding your Z-Wave network. +### Option `log_level` (optional) + +This option sets the log level of Z-Wave JS. Valid options are: +- silly +- debug +- verbose +- http +- info +- warn +- error + +If no `log_level` is specified, the log level will be set to the level set in +the Supervisor. + ### Option `emulate_hardware` (optional) If you don't have a USB stick, you can use a fake stick for testing purposes. diff --git a/zwave_js/config.json b/zwave_js/config.json index db8a8ae..65ccc1f 100644 --- a/zwave_js/config.json +++ b/zwave_js/config.json @@ -18,11 +18,13 @@ "discovery": ["zwave_js"], "options": { "device": null, - "network_key": "" + "network_key": "", + "log_level": "info" }, "schema": { "device": "device(subsystem=tty)", "network_key": "match(|[0-9a-fA-F]{32,32})", + "log_level": "list(silly|debug|verbose|http|info|warn|error)?", "emulate_hardware": "bool?" }, "image": "homeassistant/{arch}-addon-zwave_js" diff --git a/zwave_js/rootfs/etc/cont-init.d/config.sh b/zwave_js/rootfs/etc/cont-init.d/config.sh index 6f07a9d..bcc7796 100644 --- a/zwave_js/rootfs/etc/cont-init.d/config.sh +++ b/zwave_js/rootfs/etc/cont-init.d/config.sh @@ -30,11 +30,19 @@ else network_key=$(bashio::config 'network_key') fi +if ! bashio::config.has_value 'log_level'; then + log_level=$(bashio::info.logging) + bashio::log.info "No log level specified, falling back to Supervisor" + bashio::log.info "log level (${log_level})..." +else + log_level=$(bashio::config 'log_level') +fi + # Generate config bashio::var.json \ network_key "${network_key}" \ - logging "$(bashio::info.logging)" \ + log_level "${log_level}" \ | tempio \ -template /usr/share/tempio/zwave_config.conf \ -out /etc/zwave_config.json diff --git a/zwave_js/rootfs/usr/share/tempio/zwave_config.conf b/zwave_js/rootfs/usr/share/tempio/zwave_config.conf index bb7487f..22fc223 100644 --- a/zwave_js/rootfs/usr/share/tempio/zwave_config.conf +++ b/zwave_js/rootfs/usr/share/tempio/zwave_config.conf @@ -1,7 +1,7 @@ { "logConfig": { "enabled": true, - "level": {{ if eq .logging "debug" }}5{{ else }}2{{ end }}, + "level": "{{ .log_level }}", "forceConsole": true }, "storage": {