From 6cd2579672cf396eca311be86786f61866847778 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 14 Mar 2019 19:39:26 +0100 Subject: [PATCH] :sparkles: Adds debug on/off check command --- lib/bashio.sh | 2 ++ lib/debug.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 lib/debug.sh diff --git a/lib/bashio.sh b/lib/bashio.sh index bc18fcc..aa51971 100644 --- a/lib/bashio.sh +++ b/lib/bashio.sh @@ -54,6 +54,8 @@ source "${__BASHIO_LIB_DIR}/addons.sh" source "${__BASHIO_LIB_DIR}/api.sh" # shellcheck source=config.sh source "${__BASHIO_LIB_DIR}/config.sh" +# shellcheck source=debug.sh +source "${__BASHIO_LIB_DIR}/debug.sh" # shellcheck source=exit.sh source "${__BASHIO_LIB_DIR}/exit.sh" # shellcheck source=hardware.sh diff --git a/lib/debug.sh b/lib/debug.sh new file mode 100644 index 0000000..30fe18c --- /dev/null +++ b/lib/debug.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# ============================================================================== +# Community Hass.io Add-ons: Bashio +# Bashio is an bash function library for use with Hass.io add-ons. +# +# It contains a set of commonly used operations and can be used +# to be included in add-on scripts to reduce code duplication across add-ons. +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Checks if we are currently running in debug mode, based on the log module. +# ------------------------------------------------------------------------------ +bashio::debug() { + if [[ "${__BASHIO_LOG_LEVEL}" -lt "${__BASHIO_LOG_LEVEL_DEBUG}" ]]; then + return "${__BASHIO_EXIT_NOK}" + fi + + return "${__BASHIO_EXIT_OK}" +}