Skip to content
Snippets Groups Projects
Commit 7df23cab authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

add log_metadata function

parent 1c53662f
No related branches found
No related tags found
1 merge request!28improve machine readable logging
Pipeline #369099 passed
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment