| ## Note that this file is not auto generated, it is what generates the |
| ## elog-gen.hpp file |
| // This file was autogenerated. Do not edit! |
| // See elog-gen.py for more details |
| #pragma once |
| |
| #include <string> |
| #include <tuple> |
| #include <type_traits> |
| #include <phosphor-logging/log.hpp> |
| |
| namespace phosphor |
| { |
| |
| namespace logging |
| { |
| |
| % for index, name in enumerate(errors): |
| <% |
| ## Ex: name: xyz.openbmc_project.Error.Callout.Device |
| namespaces = name.split('.') |
| ## classname is the last name item (Device) |
| classname = namespaces[-1] |
| ## namespaces are all the name items except the last one |
| namespaces = namespaces[:-1] |
| %>\ |
| % for s in namespaces: |
| namespace ${s} |
| { |
| % endfor |
| namespace Error |
| { |
| namespace _${classname} |
| { |
| <% |
| meta_list = [] |
| if(name in meta): |
| meta_list = meta[name] |
| %>\ |
| |
| % for b in meta_list: |
| struct ${b} |
| { |
| static constexpr auto str = "${meta_data[b]['str']}"; |
| static constexpr auto str_short = "${meta_data[b]['str_short']}"; |
| using type = std::tuple<std::decay_t<decltype(str)>,${meta_data[b]['type']}>; |
| explicit constexpr ${b}(${meta_data[b]['type']} a) : _entry(entry(str, a)) {}; |
| type _entry; |
| }; |
| % endfor |
| |
| } // namespace _${classname} |
| <% |
| meta_string = "" |
| if(meta_list): |
| meta_string = ', '.join(meta_list) |
| parent_meta = [] |
| |
| parent = parents[name] |
| while parent: |
| tmpparent = parent.split('.') |
| ## Name is the last item |
| parent_name = tmpparent[-1] |
| ## namespaces are all the name items except the last one |
| parent_namespace = '::'.join(tmpparent[:-1]) |
| parent_meta += [parent_namespace + "::Error::" + parent_name + "::" + |
| p for p in meta[parent]] |
| parent_meta_short = ', '.join(meta[parent]) |
| if(meta_string): |
| meta_string = meta_string + ", " + parent_meta_short |
| else: |
| meta_string = parent_meta_short |
| parent = parents[parent] |
| %> |
| struct ${classname} |
| { |
| 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_list: |
| using ${b} = _${classname}::${b}; |
| % endfor |
| % for b in parent_meta: |
| using ${b.split("::").pop()} = ${b}; |
| % endfor |
| using metadata_types = std::tuple<${meta_string}>; |
| }; |
| |
| } // namespace Error |
| % for s in reversed(namespaces): |
| } // namespace ${s} |
| % endfor |
| |
| % endfor |
| |
| } // namespace logging |
| |
| } // namespace phosphor |