diff --git a/changelog.txt b/changelog.txt index 2033fe1..30088b3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ Version 0.3.1 (2018-07-15) -- Fix SESAME / SESAME_TOTP_SECRET bug (Issue #103) -- Added client IP to network status modal +- Fix SESAME / SESAME_TOTP_SECRET bug (Issue #103) @danielperna84 +- Added client IP to network status modal @danielperna84 +- Allow setting logging level with environment variable HC_LOGLEVEL @danielperna84 Version 0.3.0 (2018-07-13) - Allow passing settings via environment variables (Issue #100) @danielperna84 diff --git a/configurator.py b/configurator.py index 4bec377..2487ea0 100755 --- a/configurator.py +++ b/configurator.py @@ -84,7 +84,15 @@ NOTIFY_SERVICE_DEFAULT = "persistent_notification.create" NOTIFY_SERVICE = NOTIFY_SERVICE_DEFAULT ### End of options -LOGLEVEL = logging.INFO +LOGLEVEL_MAPPING = { + "critical": logging.CRITICAL, + "error": logging.ERROR, + "warning": logging.WARNING, + "info": logging.INFO, + "debug": logging.DEBUG +} +DEFAULT_LOGLEVEL = "info" +LOGLEVEL = LOGLEVEL_MAPPING.get(os.environ.get("HC_LOGLEVEL", DEFAULT_LOGLEVEL)) LOG = logging.getLogger(__name__) LOG.setLevel(LOGLEVEL) SO = logging.StreamHandler(sys.stdout) @@ -3438,6 +3446,8 @@ def load_settings(settingsfile): if os.path.isfile(settingsfile): with open(settingsfile) as fptr: settings = json.loads(fptr.read()) + LOG.debug("Settings from file:") + LOG.debug(settings) except Exception as err: LOG.warning(err) LOG.warning("Not loading settings from file") @@ -3457,6 +3467,8 @@ def load_settings(settingsfile): elif key[len(ENV_PREFIX):] in ["ALLOWED_NETWORKS", "BANNED_IPS", "IGNORE_PATTERN"]: value = value.split(',') settings[key[len(ENV_PREFIX):]] = value + LOG.debug("Settings after looking at environment:") + LOG.debug(settings) GIT = settings.get("GIT", GIT) if GIT: try: