diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-01-17 04:25:22 -0600 |
---|---|---|
committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-01-27 10:42:17 -0600 |
commit | 160d3e0b810f6c5f582c7daf906ce0c99cd4194e (patch) | |
tree | 6c918b816030b51e3c927583002a10d92a7aa66e /tools/phosphor-logging | |
parent | 9916119f0daad8bd5b3fbd926ada9a023949f311 (diff) | |
download | phosphor-logging-160d3e0b810f6c5f582c7daf906ce0c99cd4194e.tar.gz phosphor-logging-160d3e0b810f6c5f582c7daf906ce0c99cd4194e.zip |
elog-gen.py : read multiple error yaml files
This change enables the elog-gen script to look at more than one error
yaml file (and corresponding metadata yaml file). The input to the
script had to be changed to a yaml directory, containing
error yaml files, instead of a single error yaml file.
The reason to support reading multiple error yaml files is that,
without this, applications have to all dump their errors in a single big
error yaml file. Now it's possible to write application/domain specific
error yaml files; they just need to be exported to the same location,
from where elog-gen.py can pick them.
Change-Id: I9418bf0e0b54a7b7f7701b337649cb8eb4c54913
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'tools/phosphor-logging')
-rw-r--r-- | tools/phosphor-logging/templates/elog-gen-template.mako.hpp | 26 | ||||
-rw-r--r-- | tools/phosphor-logging/templates/elog-lookup-template.mako.cpp | 2 |
2 files changed, 14 insertions, 14 deletions
diff --git a/tools/phosphor-logging/templates/elog-gen-template.mako.hpp b/tools/phosphor-logging/templates/elog-gen-template.mako.hpp index 5c11c1b..1ff9150 100644 --- a/tools/phosphor-logging/templates/elog-gen-template.mako.hpp +++ b/tools/phosphor-logging/templates/elog-gen-template.mako.hpp @@ -15,21 +15,22 @@ namespace phosphor namespace logging { - % for a in errors: + % for index, name in enumerate(errors): <% - namespaces = elog_yaml.split('/') - namespaces.pop() - classname = errors[a] + namespaces = error_namespace.split('/') + ## In case someone provided a error_namespace ending with '/', remove the + ## last split string, which would be an empty string. + if not namespaces[-1]: + namespaces = namespaces[:-1] + classname = name %>\ % for s in namespaces: namespace ${s} { % endfor -namespace Error -{ namespace _${classname} { - % for b in meta[a]: + % for b in meta[index]: struct ${b} { static constexpr auto str = "${meta_data[b]['str']}"; @@ -41,18 +42,17 @@ struct ${b} % endfor } // namespace _${classname} -<% meta_string = ', '.join(meta[a]) %> +<% meta_string = ', '.join(meta[index]) %> struct ${classname} { - static constexpr auto err_code = "${errors[a]}"; - static constexpr auto err_msg = "${error_msg[errors[a]]}"; - static constexpr auto L = level::${error_lvl[errors[a]]}; - % for b in meta[a]: + static constexpr auto err_code = "${name}"; + static constexpr auto err_msg = "${error_msg[name]}"; + static constexpr auto L = level::${error_lvl[name]}; + % for b in meta[index]: using ${b} = _${classname}::${b}; % endfor using metadata_types = std::tuple<${meta_string}>; }; -} // namespace Error % for s in reversed(namespaces): } // namespace ${s} % endfor diff --git a/tools/phosphor-logging/templates/elog-lookup-template.mako.cpp b/tools/phosphor-logging/templates/elog-lookup-template.mako.cpp index a96760e..be4ff96 100644 --- a/tools/phosphor-logging/templates/elog-lookup-template.mako.cpp +++ b/tools/phosphor-logging/templates/elog-lookup-template.mako.cpp @@ -16,7 +16,7 @@ namespace logging std::map<std::string,std::vector<std::string>> g_errMetaMap = { % for a in errors: <% meta_string = '\",\"'.join(meta[a]) %> \ - {"${errors[a]}",{"${meta_string}"}}, + {"${a}",{"${meta_string}"}}, % endfor }; |