summaryrefslogtreecommitdiffstats
path: root/tools/phosphor-logging/templates/elog-gen-template.mako.hpp
blob: b0dec609ea59ff28434bd501f22630b85d9e22b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
## 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 "log.hpp"

namespace phosphor
{

namespace logging
{

    % for index, name in enumerate(errors):
<%
    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 _${classname}
{
    % for b in meta[name]:
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 = ', '.join(meta[name])
    parent_meta = []

    parent = parents[name]
    while parent:
        parent_meta += [parent + "::" + p for p in meta[parent]]
        parent_meta_short = ', '.join(meta[parent])
        meta_string = 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[name]:
    using ${b} = _${classname}::${b};
    % endfor
    % for b in parent_meta:
    using ${b.split("::").pop()} = ${b};
    % endfor
    using metadata_types = std::tuple<${meta_string}>;
};
% for s in reversed(namespaces):
} // namespace ${s}
% endfor

    % endfor

} // namespace logging

} // namespace phosphor
OpenPOWER on IntegriCloud