diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-02-28 02:18:09 -0600 |
---|---|---|
committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-03-15 09:20:14 -0500 |
commit | 38f6974485cd7cb01e767bb501f32f35100adee4 (patch) | |
tree | 651fe3abd6730520e5801f316f6ebc191571b472 /tools | |
parent | 16e8754504906eaea0c8b4aba23e96fef3e5285c (diff) | |
download | phosphor-logging-38f6974485cd7cb01e767bb501f32f35100adee4.tar.gz phosphor-logging-38f6974485cd7cb01e767bb501f32f35100adee4.zip |
elog-gen.py : consume metadata 'process' keyword
Add a new mako template to aid elog-gen.py to generate code for handling
the metadata 'process' keyword.
Change-Id: I720ac1e30cf566f5a6bfe090faec6da9742f7423
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/elog-gen.py | 18 | ||||
-rw-r--r-- | tools/phosphor-logging/templates/elog-process-metadata.mako.cpp | 24 |
2 files changed, 37 insertions, 5 deletions
diff --git a/tools/elog-gen.py b/tools/elog-gen.py index 469248f..29ff52f 100755 --- a/tools/elog-gen.py +++ b/tools/elog-gen.py @@ -120,6 +120,7 @@ def gen_elog_hpp(i_yaml_dir, i_test_dir, i_output_hpp, meta = dict() # The meta data names associated (ERRNO, FILE_NAME, ...) meta_data = dict() # The meta data info (type, format) parents = dict() + metadata_process = dict() # metadata that have the 'process' keyword set error_yamls = get_error_yaml_files(i_yaml_dir, i_test_dir) @@ -150,7 +151,8 @@ def gen_elog_hpp(i_yaml_dir, i_test_dir, i_output_hpp, error_lvl, meta, meta_data, - parents)) + parents, + metadata_process)) if(not check_error_inheritance(errors, parents)): print("Error - failed to validate error inheritance") @@ -164,10 +166,13 @@ def gen_elog_hpp(i_yaml_dir, i_test_dir, i_output_hpp, template = Template(filename=template_path) f = open(i_output_hpp, 'w') f.write(template.render( - errors=errors, error_msg=error_msg, - error_lvl=error_lvl, meta=meta, + errors=errors, + error_msg=error_msg, + error_lvl=error_lvl, + meta=meta, meta_data=meta_data, - parents=parents)) + parents=parents, + metadata_process=metadata_process)) f.close() @@ -185,7 +190,8 @@ def get_elog_data(i_elog_yaml, i_namespace namespace data o_elog_data error metadata """ - errors, error_msg, error_lvl, meta, meta_data, parents = o_elog_data + (errors, error_msg, error_lvl, meta, + meta_data, parents, metadata_process) = o_elog_data ifile = yaml.safe_load(open(i_elog_yaml)) mfile = yaml.safe_load(open(i_elog_meta_yaml)) for i in mfile: @@ -222,6 +228,8 @@ def get_elog_data(i_elog_yaml, meta_data[str_short]['str'] = j['str'] meta_data[str_short]['str_short'] = str_short meta_data[str_short]['type'] = get_cpp_type(j['type']) + if(('process' in j) and (True == j['process'])): + metadata_process[str_short] = fullname + "." + str_short meta[fullname] = tmp_meta # Debug diff --git a/tools/phosphor-logging/templates/elog-process-metadata.mako.cpp b/tools/phosphor-logging/templates/elog-process-metadata.mako.cpp new file mode 100644 index 0000000..267413d --- /dev/null +++ b/tools/phosphor-logging/templates/elog-process-metadata.mako.cpp @@ -0,0 +1,24 @@ +## Note that this file is not auto generated, it is what generates the +## elog-metadata-postprocess.cpp file +// This file was autogenerated. Do not edit! +// See elog-gen.py for more details + +#include <string> +#include <vector> +#include <functional> +#include <phosphor-logging/elog-errors.hpp> +#include "elog_meta.hpp" + +using namespace phosphor::logging; +using namespace example::xyz::openbmc_project::Example::Elog; +using namespace std::placeholders; + +extern const std::map<metadata::Metadata, + std::function<metadata::associations::Type>> meta = { + % for key, value in metadata_process.iteritems(): +<% + type = value.replace(".", "::") +%>\ + {"${key}", metadata::associations::build<${type}>}, + % endfor +}; |