summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2018-07-19 10:29:56 +0800
committerLei YU <mine260309@gmail.com>2018-07-20 17:02:20 +0800
commit80aa4762f78f1044d15c918d72316aa388ba0a02 (patch)
tree760f5e75f7055e8958cfd6925fe882e1ce992728 /tools
parent8f6f7fc3ccea4a1a32d17f4c335cbe7040fde068 (diff)
downloadphosphor-logging-80aa4762f78f1044d15c918d72316aa388ba0a02.tar.gz
phosphor-logging-80aa4762f78f1044d15c918d72316aa388ba0a02.zip
elog-gen: allow inherits from errors without meta
Previously, elog-gen only support inherits from errors that have meta, and if we inherit from an error without meta, e.g. Common.InternalFailure, we get build error like: KeyError: 'xyz.openbmc_project.Common.InternalFailure' This commit makes elog-gen to allow such case, so it is possible to allow a base error without meta, and inheriting error with additional error, e.g. # In Common: - name: NotAllowed ## No meta # In Time: - name: NotAllowed inherits: - xyz.openbmc_project.Common.NotAllowed meta: - str: "OWNER=%s" type: string - str: "SYNC_METHOD=%s" type: string Note: the "inherit" here does not mean the the error inherits from base errors in c++ class, it just makes error "logically" inherits base errors. And in future commits we could make it "really" inherits base errors in c++ level. Tested: Verify phosphor-logging builds correctly with above example error interfaces, and service is able to use such errors with elog. Change-Id: I8dccd7112881e3eb77a8f6ec62a532062348d2ef Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/elog-gen.py6
-rw-r--r--tools/phosphor-logging/templates/elog-gen-template.mako.hpp11
2 files changed, 11 insertions, 6 deletions
diff --git a/tools/elog-gen.py b/tools/elog-gen.py
index 9169a6e..825fc0f 100755
--- a/tools/elog-gen.py
+++ b/tools/elog-gen.py
@@ -230,8 +230,10 @@ def get_elog_data(i_elog_yaml,
if 'inherits' in match:
parents[fullname] = match['inherits'][0]
+ # Put all errors in meta[] even the meta is empty
+ # so that child errors could inherits such error without meta
+ tmp_meta = []
if 'meta' in match:
- tmp_meta = []
# grab all the meta data fields and info
for i in match['meta']:
str_short = i['str'].split('=')[0]
@@ -242,7 +244,7 @@ def get_elog_data(i_elog_yaml,
meta_data[str_short]['type'] = get_cpp_type(i['type'])
if ('process' in i) and (True == i['process']):
metadata_process[str_short] = fullname + "." + str_short
- meta[fullname] = tmp_meta
+ meta[fullname] = tmp_meta
# Debug
# for i in errors:
diff --git a/tools/phosphor-logging/templates/elog-gen-template.mako.hpp b/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
index 23d8c08..0d156ad 100644
--- a/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
+++ b/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
@@ -103,10 +103,13 @@ struct ${b}
parent_meta += [parent_namespace + "::" + 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
+ # The parent may have empty meta,
+ # so only add parent meta when it exists
+ if (parent_meta_short):
+ if(meta_string):
+ meta_string = meta_string + ", " + parent_meta_short
+ else:
+ meta_string = parent_meta_short
parent = parents[parent]
if example_yaml:
OpenPOWER on IntegriCloud