1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-18 06:11:49 -05:00

Dump out the config during startup

This patch adds the dumping out of a flattened config to the log
at startup.  This is helpful for seeing what aprsd server is actually
using for config entries at startup and since it's in the log, you can
reference it.
This commit is contained in:
Hemna 2021-07-05 10:57:22 -04:00
parent 3ae5717452
commit 9a1ab1c0d6
2 changed files with 22 additions and 0 deletions

View File

@ -445,6 +445,7 @@ def server(
if not quiet: if not quiet:
click.echo("Load config") click.echo("Load config")
config = utils.parse_config(config_file) config = utils.parse_config(config_file)
# Force setting the config to the modules that need it # Force setting the config to the modules that need it
@ -460,6 +461,14 @@ def server(
else: else:
LOG.info(msg) 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): if config["aprsd"].get("trace", False):
trace.setup_tracing(["method", "api"]) trace.setup_tracing(["method", "api"])
LOG.info("APRSD Started version: {}".format(aprsd.__version__)) LOG.info("APRSD Started version: {}".format(aprsd.__version__))

View File

@ -1,5 +1,6 @@
"""Utilities and helper functions.""" """Utilities and helper functions."""
import collections
import errno import errno
import functools import functools
import logging import logging
@ -394,3 +395,15 @@ def _check_version():
# Lets put up an error and move on. We might not # Lets put up an error and move on. We might not
# have internet in this aprsd deployment. # have internet in this aprsd deployment.
return 1, "Couldn't check for new version of APRSD" 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)