Merge pull request #63 from craigerl/dump_config

Dump out the config during startup
This commit is contained in:
Walter A. Boring IV 2021-07-05 11:02:17 -04:00 committed by GitHub
commit 13be30f772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -445,6 +445,7 @@ def server(
if not quiet:
click.echo("Load config")
config = utils.parse_config(config_file)
# Force setting the config to the modules that need it
@ -460,6 +461,14 @@ def server(
else:
LOG.info(msg)
flat_config = utils.flatten_dict(config)
LOG.info("Using CONFIG values:")
for x in flat_config:
if "password" in x or "aprsd.web.users.admin" in x:
LOG.info("{} = XXXXXXXXXXXXXXXXXXX".format(x))
else:
LOG.info("{} = {}".format(x, flat_config[x]))
if config["aprsd"].get("trace", False):
trace.setup_tracing(["method", "api"])
LOG.info("APRSD Started version: {}".format(aprsd.__version__))

View File

@ -1,5 +1,6 @@
"""Utilities and helper functions."""
import collections
import errno
import functools
import logging
@ -394,3 +395,15 @@ def _check_version():
# Lets put up an error and move on. We might not
# have internet in this aprsd deployment.
return 1, "Couldn't check for new version of APRSD"
def flatten_dict(d, parent_key="", sep="."):
"""Flatten a dict to key.key.key = value."""
items = []
for k, v in d.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, collections.MutableMapping):
items.extend(flatten_dict(v, new_key, sep=sep).items())
else:
items.append((new_key, v))
return dict(items)