Fix types in error-logging YAML to match openbmc standards
Change-Id: If5e2e534740f0675ba9294905ae531e015aed85a
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/tools/elog-gen.py b/tools/elog-gen.py
index 57d5050..c72aa98 100755
--- a/tools/elog-gen.py
+++ b/tools/elog-gen.py
@@ -19,6 +19,21 @@
import os
+def get_cpp_type(i_type):
+ typeMap = {
+ 'int16': 'int16_t',
+ 'int32': 'int32_t',
+ 'int64': 'int64_t',
+ 'uint16': 'uint16_t',
+ 'uint32': 'uint32_t',
+ 'uint64': 'uint64_t',
+ 'double': 'double',
+ # const char* aids usage of constexpr
+ 'string': 'const char*'}
+
+ return typeMap[i_type]
+
+
def gen_elog_hpp(i_rootdir, i_elog_yaml, i_elog_meta_yaml,
i_input_mako, i_output_hpp):
r"""
@@ -66,7 +81,7 @@
meta_data[str_short] = {}
meta_data[str_short]['str'] = j['str']
meta_data[str_short]['str_short'] = str_short
- meta_data[str_short]['type'] = j['type']
+ meta_data[str_short]['type'] = get_cpp_type(j['type'])
meta.append(tmp_meta)
err_count += 1
@@ -83,7 +98,7 @@
f = open(i_output_hpp, 'w')
f.write(mytemplate.render(errors=errors, error_msg=error_msg,
error_lvl=error_lvl, meta=meta,
- meta_data=meta_data,elog_yaml=i_elog_yaml))
+ meta_data=meta_data, elog_yaml=i_elog_yaml))
f.close()
diff --git a/tools/example/xyz/openbmc_project/Example/Elog.metadata.yaml b/tools/example/xyz/openbmc_project/Example/Elog.metadata.yaml
index 9ca4a4e..244127c 100644
--- a/tools/example/xyz/openbmc_project/Example/Elog.metadata.yaml
+++ b/tools/example/xyz/openbmc_project/Example/Elog.metadata.yaml
@@ -2,18 +2,18 @@
level: INFO
meta:
- str: "ERRNUM=0x%.4X"
- type: int
+ type: uint16
- str: FILE_PATH=%s
- type: const char*
+ type: string
- str: FILE_NAME=%s
- type: const char*
+ type: string
- name: TestErrorTwo
level: ERR
meta:
- str: DEV_ADDR=0x%.8X
- type: int
+ type: uint32
- str: DEV_ID=%u
- type: int
+ type: uint32
- str: DEV_NAME=%s
- type: const char*
+ type: string
diff --git a/tools/phosphor-logging/templates/elog-gen-template.mako.hpp b/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
index b9d3d5e..5c11c1b 100644
--- a/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
+++ b/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
@@ -4,6 +4,7 @@
// See elog-gen.py for more details
#pragma once
+#include <string>
#include <tuple>
#include <type_traits>
#include "log.hpp"