diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py index 5b6538b65fda4d335473f6d6e9245cfccf7c9eb9..87486796ac0c3be2fd4957cb3807da1e4d9e9043 100755 --- a/mpsd-software-environment.py +++ b/mpsd-software-environment.py @@ -36,11 +36,33 @@ config_vars = { "logs/mpsd_spack_ver_toolchains_" f"{datetime.datetime.now().replace(microsecond=0).isoformat()}.log" ), + "metadata_tag_open": "!<meta>", + "metadata_tag_close": "</meta>!", # TODO: modify toolchains,mpsd_spack_ver when the variable is available "spack_environments_repo": "https://gitlab.gwdg.de/mpsd-cs/spack-environments.git", } +def log_metadata(key: str, value: str) -> None: + """Log metadata to the log file. + + This function logs metadata to the log file. The metadata is + enclosed in a tag, so that it can be easily found in the log file. + logging module is used to write the metadata to the log file. + + Parameters + ---------- + key : str + key of the metadata + value : str + value of the metadata + returns : None + """ + logging.info( + f"{config_vars['metadata_tag_open']}{key}:{value}{config_vars['metadata_tag_close']}" + ) + + def set_up_logging(loglevel="warning", filename=None): """Set up logging.